From 4cd18ee32d39c5e9896e528f5ef87a9c92a694c2 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Mon, 18 Oct 2010 15:53:31 +0000 Subject: [PATCH] Improvements to examples and markup fixes for class-based view docs. git-svn-id: http://code.djangoproject.com/svn/django/trunk@14257 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/ref/class-based-views.txt | 10 ++++------ docs/topics/class-based-views.txt | 10 +++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/docs/ref/class-based-views.txt b/docs/ref/class-based-views.txt index 4f800e1fd9..27c8ed6f23 100644 --- a/docs/ref/class-based-views.txt +++ b/docs/ref/class-based-views.txt @@ -313,9 +313,8 @@ Note that ``page`` *must* be either a valid page number or the value .. method:: MultipleObjectMixin.paginate_queryset(queryset, page_size) - Returns a 4-tuple containing:: - - (``paginator``, ``page``, ``object_list``, ``is_paginated``) + Returns a 4-tuple containing (``paginator``, ``page``, + ``object_list``, ``is_paginated``). constructed by paginating ``queryset`` into pages of size ``page_size``. If the request contains a ``page`` argument, either as a captured @@ -819,9 +818,8 @@ for which data is available. .. method:: ArchiveView.get_dated_items(): - Returns a 3-tuple containing:: - - (date_list, latest, extra_context) + Returns a 3-tuple containing (``date_list``, ``latest``, + ``extra_context``). ``date_list`` is the list of dates for which data is available. ``object_list`` is the list of objects ``extra_context`` is a diff --git a/docs/topics/class-based-views.txt b/docs/topics/class-based-views.txt index 83f060ac94..bdd5759355 100644 --- a/docs/topics/class-based-views.txt +++ b/docs/topics/class-based-views.txt @@ -250,7 +250,7 @@ more:: def get_context_data(self, **kwargs): # Call the base implementation first to get a context - context = DetailView.get_context_data(self, **kwargs) + context = super(DetailView, self).get_context_data(**kwargs) # Add in a QuerySet of all the books context['book_list'] = Book.objects.all() return context @@ -275,7 +275,7 @@ specify the list of objects using the ``queryset`` argument:: context_object_name = "publisher" queryset = Publisher.object.all() -Specifying ``mode = Publisher`` is really just shorthand for saying +Specifying ``model = Publisher`` is really just shorthand for saying ``queryset = Publisher.objects.all()``. However, by using ``queryset`` to define a filtered list of objects you can be more specific about the objects that will be visible in the view (see :doc:`/topics/db/queries` @@ -387,7 +387,7 @@ use it in the template:: def get_context_data(self, **kwargs): # Call the base implementation first to get a context - context = ListView.get_context_data(self, **kwargs) + context = super(ListView, self).get_context_data(**kwargs) # Add in the publisher context['publisher'] = self.publisher return context @@ -441,7 +441,7 @@ object, so we simply override it and wrap the call:: def get_object(self, **kwargs): # Call the superclass - object = DetailView.get_object(self, **kwargs) + object = super(DetailView, self).get_object(**kwargs) # Record the lass accessed date object.last_accessed = datetime.datetime.now() object.save() @@ -530,6 +530,6 @@ requested:: return SingleObjectTemplateResponseMixin.render_to_response(self, context) Because of the way that Python resolves method overloading, the local -:func:``render_to_response()`` implementation will override the +:func:`render_to_response()` implementation will override the versions provided by :class:`JSONResponseMixin` and :class:`~django.views.generic.detail.SingleObjectTemplateResponseMixin`.