diff options
Diffstat (limited to 'docs/generic_views.txt')
| -rw-r--r-- | docs/generic_views.txt | 97 |
1 files changed, 53 insertions, 44 deletions
diff --git a/docs/generic_views.txt b/docs/generic_views.txt index 597ef96104..5b978af1de 100644 --- a/docs/generic_views.txt +++ b/docs/generic_views.txt @@ -62,6 +62,15 @@ Most generic views require the ``queryset`` key, which is a ``QuerySet`` instance; see the `database API docs`_ for more information about ``Queryset`` objects. +Most views also take an optional ``extra_context`` dictionary that you can use +to pass any auxiliary information you wish to the view. The values in the +``extra_context`` dictionary can be either functions (or other callables) or +other objects. Functions are evaluated just before they are passed to the +template. However, note that QuerySets retrieve and cache their data when they +are first evaluated, so if you want to pass in a QuerySet via +``extra_context`` that is always fresh you need to wrap it in a function or +lambda that returns the QuerySet. + .. _database API docs: http://www.djangoproject.com/documentation/db_api/ "Simple" generic views @@ -160,10 +169,10 @@ a date in the *future* are not included. * ``template_loader``: The template loader to use when loading the template. By default, it's ``django.template.loader``. - * ``extra_context``: A dictionary of values to add to the template context. - If a value in the dictionary is callable, the generic view will call it - just before rendering the template. By default, this is an empty - dictionary. + * ``extra_context``: A dictionary of values to add to the template + context. By default, this is an empty dictionary. + dictionary is callable, the generic view will call it + just before rendering the template. * ``allow_empty``: A boolean specifying whether to display the page if no objects are available. If this is ``False`` and no objects are available, @@ -225,10 +234,10 @@ with a date in the *future* are not displayed. * ``template_loader``: The template loader to use when loading the template. By default, it's ``django.template.loader``. - * ``extra_context``: A dictionary of values to add to the template context. - If a value in the dictionary is callable, the generic view will call it - just before rendering the template. By default, this is an empty - dictionary. + * ``extra_context``: A dictionary of values to add to the template + context. By default, this is an empty dictionary. If a value in the + dictionary is callable, the generic view will call it + just before rendering the template. * ``allow_empty``: A boolean specifying whether to display the page if no objects are available. If this is ``False`` and no objects are available, @@ -287,10 +296,10 @@ date in the *future* are not displayed. * ``template_loader``: The template loader to use when loading the template. By default, it's ``django.template.loader``. - * ``extra_context``: A dictionary of values to add to the template context. - If a value in the dictionary is callable, the generic view will call it - just before rendering the template. By default, this is an empty - dictionary. + * ``extra_context``: A dictionary of values to add to the template + context. By default, this is an empty dictionary. If a value in the + dictionary is callable, the generic view will call it + just before rendering the template. * ``allow_empty``: A boolean specifying whether to display the page if no objects are available. If this is ``False`` and no objects are available, @@ -360,10 +369,10 @@ in the *future* are not displayed. * ``template_loader``: The template loader to use when loading the template. By default, it's ``django.template.loader``. - * ``extra_context``: A dictionary of values to add to the template context. - If a value in the dictionary is callable, the generic view will call it - just before rendering the template. By default, this is an empty - dictionary. + * ``extra_context``: A dictionary of values to add to the template + context. By default, this is an empty dictionary. If a value in the + dictionary is callable, the generic view will call it + just before rendering the template. * ``allow_empty``: A boolean specifying whether to display the page if no objects are available. If this is ``False`` and no objects are available, @@ -436,10 +445,10 @@ a 404 error, regardless of whether any objects exist for future days. * ``template_loader``: The template loader to use when loading the template. By default, it's ``django.template.loader``. - * ``extra_context``: A dictionary of values to add to the template context. - If a value in the dictionary is callable, the generic view will call it - just before rendering the template. By default, this is an empty - dictionary. + * ``extra_context``: A dictionary of values to add to the template + context. By default, this is an empty dictionary. If a value in the + dictionary is callable, the generic view will call it + just before rendering the template. * ``allow_empty``: A boolean specifying whether to display the page if no objects are available. If this is ``False`` and no objects are available, @@ -543,10 +552,10 @@ A page representing an individual object. * ``template_loader``: The template loader to use when loading the template. By default, it's ``django.template.loader``. - * ``extra_context``: A dictionary of values to add to the template context. - If a value in the dictionary is callable, the generic view will call it - just before rendering the template. By default, this is an empty - dictionary. + * ``extra_context``: A dictionary of values to add to the template + context. By default, this is an empty dictionary. If a value in the + dictionary is callable, the generic view will call it + just before rendering the template. * ``context_processors``: A list of template-context processors to apply to the view's template. See the `RequestContext docs`_. @@ -600,10 +609,10 @@ A page representing a list of objects. * ``template_loader``: The template loader to use when loading the template. By default, it's ``django.template.loader``. - * ``extra_context``: A dictionary of values to add to the template context. - If a value in the dictionary is callable, the generic view will call it - just before rendering the template. By default, this is an empty - dictionary. + * ``extra_context``: A dictionary of values to add to the template + context. By default, this is an empty dictionary. If a value in the + dictionary is callable, the generic view will call it + just before rendering the template. * ``allow_empty``: A boolean specifying whether to display the page if no objects are available. If this is ``False`` and no objects are available, @@ -697,10 +706,10 @@ A page representing an individual object. * ``template_loader``: The template loader to use when loading the template. By default, it's ``django.template.loader``. - * ``extra_context``: A dictionary of values to add to the template context. - If a value in the dictionary is callable, the generic view will call it - just before rendering the template. By default, this is an empty - dictionary. + * ``extra_context``: A dictionary of values to add to the template + context. By default, this is an empty dictionary. If a value in the + dictionary is callable, the generic view will call it + just before rendering the template. * ``context_processors``: A list of template-context processors to apply to the view's template. See the `RequestContext docs`_. @@ -764,10 +773,10 @@ automatic manipulators that come with Django models. * ``template_loader``: The template loader to use when loading the template. By default, it's ``django.template.loader``. - * ``extra_context``: A dictionary of values to add to the template context. - If a value in the dictionary is callable, the generic view will call it - just before rendering the template. By default, this is an empty - dictionary. + * ``extra_context``: A dictionary of values to add to the template + context. By default, this is an empty dictionary. If a value in the + dictionary is callable, the generic view will call it + just before rendering the template. * ``context_processors``: A list of template-context processors to apply to the view's template. See the `RequestContext docs`_. @@ -843,10 +852,10 @@ object. This uses the automatic manipulators that come with Django models. * ``template_loader``: The template loader to use when loading the template. By default, it's ``django.template.loader``. - * ``extra_context``: A dictionary of values to add to the template context. - If a value in the dictionary is callable, the generic view will call it - just before rendering the template. By default, this is an empty - dictionary. + * ``extra_context``: A dictionary of values to add to the template + context. By default, this is an empty dictionary. If a value in the + dictionary is callable, the generic view will call it + just before rendering the template. * ``context_processors``: A list of template-context processors to apply to the view's template. See the `RequestContext docs`_. @@ -924,10 +933,10 @@ contain a form that POSTs to the same URL. * ``template_loader``: The template loader to use when loading the template. By default, it's ``django.template.loader``. - * ``extra_context``: A dictionary of values to add to the template context. - If a value in the dictionary is callable, the generic view will call it - just before rendering the template. By default, this is an empty - dictionary. + * ``extra_context``: A dictionary of values to add to the template + context. By default, this is an empty dictionary. If a value in the + dictionary is callable, the generic view will call it + just before rendering the template. * ``context_processors``: A list of template-context processors to apply to the view's template. See the `RequestContext docs`_. |
