summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2011-01-03 13:15:58 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2011-01-03 13:15:58 +0000
commita00e8d4e4204bfb730ba3eac2ee11ad83c8ec91b (patch)
treedc9ab2179cf3c45dbb852a44c167621fe0ef41d9 /docs
parent2a5105ac15baf68c844aa14b68b7af63a2329fc9 (diff)
Fixed #14878 -- Clarified the way verbose_name_plural is used in generic list views as a context variable. Thanks to diegueus9 for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15133 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/class-based-views.txt2
-rw-r--r--docs/topics/class-based-views.txt23
2 files changed, 17 insertions, 8 deletions
diff --git a/docs/ref/class-based-views.txt b/docs/ref/class-based-views.txt
index e8255a4381..8350fd22b2 100644
--- a/docs/ref/class-based-views.txt
+++ b/docs/ref/class-based-views.txt
@@ -428,7 +428,7 @@ FormMixin
.. method:: get_form_kwargs()
Build the keyword arguments requried to instanciate an the form.
-
+
The ``initial`` argument is set to :meth:`.get_initial`. If the
request is a ``POST`` or ``PUT``, the request data (``request.POST``
and ``request.FILES``) will also be provided.
diff --git a/docs/topics/class-based-views.txt b/docs/topics/class-based-views.txt
index 877323bcdd..516a3150ed 100644
--- a/docs/topics/class-based-views.txt
+++ b/docs/topics/class-based-views.txt
@@ -206,14 +206,23 @@ their attributes or methods.
Making "friendly" template contexts
-----------------------------------
-You might have noticed that our sample publisher list template stores all the
-publishers in a variable named ``object_list``. While this works just fine, it
-isn't all that "friendly" to template authors: they have to "just know" that
-they're dealing with publishers here. A more obvious name for that variable
-would be ``publisher_list``.
+You might have noticed that our sample publisher list template stores
+all the publishers in a variable named ``object_list``. While this
+works just fine, it isn't all that "friendly" to template authors:
+they have to "just know" that they're dealing with publishers here.
-We can change the name of that variable easily with the ``context_object_name``
-attribute - here, we'll override it in the URLconf, since it's a simple change:
+Well, if you're dealing with a Django object, this is already done for
+you. When you are dealing with an object or queryset, Django is able
+to populate the context using the verbose name (or the plural verbose
+name, in the case of a list of objects) of the object being displayed.
+This is provided in addition to the default ``object_list`` entry, but
+contains exactly the same data.
+
+If the verbose name (or plural verbose name) still isn't a good match,
+you can manually set the name of the context variable. The
+``context_object_name`` attribute on a generic view specifies the
+context variable to use. In this example, we'll override it in the
+URLconf, since it's a simple change:
.. parsed-literal::