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
This commit is contained in:
parent
2a9551a415
commit
4cd18ee32d
|
@ -313,9 +313,8 @@ Note that ``page`` *must* be either a valid page number or the value
|
||||||
|
|
||||||
.. method:: MultipleObjectMixin.paginate_queryset(queryset, page_size)
|
.. method:: MultipleObjectMixin.paginate_queryset(queryset, page_size)
|
||||||
|
|
||||||
Returns a 4-tuple containing::
|
Returns a 4-tuple containing (``paginator``, ``page``,
|
||||||
|
``object_list``, ``is_paginated``).
|
||||||
(``paginator``, ``page``, ``object_list``, ``is_paginated``)
|
|
||||||
|
|
||||||
constructed by paginating ``queryset`` into pages of size ``page_size``.
|
constructed by paginating ``queryset`` into pages of size ``page_size``.
|
||||||
If the request contains a ``page`` argument, either as a captured
|
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():
|
.. method:: ArchiveView.get_dated_items():
|
||||||
|
|
||||||
Returns a 3-tuple containing::
|
Returns a 3-tuple containing (``date_list``, ``latest``,
|
||||||
|
``extra_context``).
|
||||||
(date_list, latest, extra_context)
|
|
||||||
|
|
||||||
``date_list`` is the list of dates for which data is available.
|
``date_list`` is the list of dates for which data is available.
|
||||||
``object_list`` is the list of objects ``extra_context`` is a
|
``object_list`` is the list of objects ``extra_context`` is a
|
||||||
|
|
|
@ -250,7 +250,7 @@ more::
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
# Call the base implementation first to get a context
|
# 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
|
# Add in a QuerySet of all the books
|
||||||
context['book_list'] = Book.objects.all()
|
context['book_list'] = Book.objects.all()
|
||||||
return context
|
return context
|
||||||
|
@ -275,7 +275,7 @@ specify the list of objects using the ``queryset`` argument::
|
||||||
context_object_name = "publisher"
|
context_object_name = "publisher"
|
||||||
queryset = Publisher.object.all()
|
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``
|
``queryset = Publisher.objects.all()``. However, by using ``queryset``
|
||||||
to define a filtered list of objects you can be more specific about the
|
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`
|
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):
|
def get_context_data(self, **kwargs):
|
||||||
# Call the base implementation first to get a context
|
# 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
|
# Add in the publisher
|
||||||
context['publisher'] = self.publisher
|
context['publisher'] = self.publisher
|
||||||
return context
|
return context
|
||||||
|
@ -441,7 +441,7 @@ object, so we simply override it and wrap the call::
|
||||||
|
|
||||||
def get_object(self, **kwargs):
|
def get_object(self, **kwargs):
|
||||||
# Call the superclass
|
# Call the superclass
|
||||||
object = DetailView.get_object(self, **kwargs)
|
object = super(DetailView, self).get_object(**kwargs)
|
||||||
# Record the lass accessed date
|
# Record the lass accessed date
|
||||||
object.last_accessed = datetime.datetime.now()
|
object.last_accessed = datetime.datetime.now()
|
||||||
object.save()
|
object.save()
|
||||||
|
@ -530,6 +530,6 @@ requested::
|
||||||
return SingleObjectTemplateResponseMixin.render_to_response(self, context)
|
return SingleObjectTemplateResponseMixin.render_to_response(self, context)
|
||||||
|
|
||||||
Because of the way that Python resolves method overloading, the local
|
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
|
versions provided by :class:`JSONResponseMixin` and
|
||||||
:class:`~django.views.generic.detail.SingleObjectTemplateResponseMixin`.
|
:class:`~django.views.generic.detail.SingleObjectTemplateResponseMixin`.
|
||||||
|
|
Loading…
Reference in New Issue