diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2011-01-03 13:15:58 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2011-01-03 13:15:58 +0000 |
| commit | a00e8d4e4204bfb730ba3eac2ee11ad83c8ec91b (patch) | |
| tree | dc9ab2179cf3c45dbb852a44c167621fe0ef41d9 /docs/topics | |
| parent | 2a5105ac15baf68c844aa14b68b7af63a2329fc9 (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/topics')
| -rw-r--r-- | docs/topics/class-based-views.txt | 23 |
1 files changed, 16 insertions, 7 deletions
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:: |
