summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2011-02-14 13:04:51 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2011-02-14 13:04:51 +0000
commit06b22963eae4751d3d5f9616ba24b0f33b8158b0 (patch)
treef42d2ab670e2f35705e1890f9b872b5eb51f97c1 /docs
parenta26034ffbf8951276b79ccb298423bc809246637 (diff)
Fixed #15272 -- Altered generic views to use the guaranteed untranslated object_name, rather than the possibly translated verbose_name(_plural) for default context objects. Thanks to szczav for the report and patch.
This is BACKWARDS INCOMPATIBLE for anyone relying on the default context object names for class-based Detail and List views. To migrate, either update your templates to use the new default names, or add a context_object_name argument to your generic views. git-svn-id: http://code.djangoproject.com/svn/django/trunk@15531 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/class-based-views.txt22
-rw-r--r--docs/topics/generic-views-migration.txt3
2 files changed, 15 insertions, 10 deletions
diff --git a/docs/ref/class-based-views.txt b/docs/ref/class-based-views.txt
index 8350fd22b2..09ad0d3cec 100644
--- a/docs/ref/class-based-views.txt
+++ b/docs/ref/class-based-views.txt
@@ -162,14 +162,14 @@ SingleObjectMixin
it constructs a :class:`QuerySet` by calling the `all()` method on the
:attr:`~SingleObjectMixin.model` attribute's default manager.
- .. method:: get_context_object_name(object_list)
+ .. method:: get_context_object_name(obj)
Return the context variable name that will be used to contain the
- list of data that this view is manipulating. If ``object_list`` is a
- :class:`QuerySet` of Django objects and
+ data that this view is manipulating. If
:attr:`~SingleObjectMixin.context_object_name` is not set, the context
- name will be constructed from the verbose plural name of the model that
- the queryset is composed from.
+ name will be constructed from the ``object_name`` of the model that
+ the queryset is composed from. For example, the model ``Article``
+ would have context object named ``'article'``.
.. method:: get_context_data(**kwargs)
@@ -333,10 +333,14 @@ MultipleObjectMixin
.. method:: get_context_object_name(object_list)
- Return the context variable name that will be used to contain the list
- of data that this view is manipulating. If object_list is a queryset of
- Django objects, the context name will be verbose plural name of the
- model that the queryset is composed from.
+ Return the context variable name that will be used to contain
+ the list of data that this view is manipulating. If
+ ``object_list`` is a queryset of Django objects and
+ :attr:`~MultipleObjectMixin.context_object_name` is not set,
+ the context name will be the ``object_name`` of the model that
+ the queryset is composed from, with postfix ``'_list'``
+ appended. For example, the model ``Article`` would have a
+ context object named ``article_list``.
.. method:: get_context_data(**kwargs)
diff --git a/docs/topics/generic-views-migration.txt b/docs/topics/generic-views-migration.txt
index ab6b87e6d1..fa62f5de1f 100644
--- a/docs/topics/generic-views-migration.txt
+++ b/docs/topics/generic-views-migration.txt
@@ -72,7 +72,8 @@ The ``_list`` suffix on list views
In a function-based :class:`ListView`, the ``template_object_name``
was appended with the suffix ``'_list'`` to yield the final context
variable name. In a class-based ``ListView``, the
-``context_object_name`` is used verbatim.
+``context_object_name`` is used verbatim. The ``'_list'`` suffix
+is only applied when generating a default context object name.
The context data for ``object_list`` views
------------------------------------------