Django

Code

Changeset 2931

Show
Ignore:
Timestamp:
05/16/06 23:01:00 (2 years ago)
Author:
mtredinnick
Message:

Clarified how extra_context values are evaluated and, in particular, how to
pass in a "live" QuerySet?. Thanks to Jay Parlar for pointing out the potential
for confusion.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/generic_views.txt

    r2869 r2931  
    161161      template. By default, it's ``django.template.loader``. 
    162162 
    163     * ``extra_context``: A dictionary of values to add to the template context. 
    164       If a value in the dictionary is callable, the generic view will call it 
    165       just before rendering the template. By default, this is an empty 
    166       dictionary. 
     163    * ``extra_context``: A dictionary of values to add to the template 
     164      context. By default, this is an empty dictionary. If a value in the 
     165      dictionary is callable, the generic view will call it 
     166      just before rendering the template. If it is not callable, it will be 
     167      evaluated once, at import time. Note that QuerySets are not callable, so 
     168      if you want to pass in a QuerySet in ``extra_context`` and have it 
     169      evaluated at render time, you need to wrap it in a function (that 
     170      returns the QuerySet). 
    167171 
    168172    * ``allow_empty``: A boolean specifying whether to display the page if no 
     
    226230      template. By default, it's ``django.template.loader``. 
    227231 
    228     * ``extra_context``: A dictionary of values to add to the template context. 
    229       If a value in the dictionary is callable, the generic view will call it 
    230       just before rendering the template. By default, this is an empty 
    231       dictionary. 
     232    * ``extra_context``: A dictionary of values to add to the template 
     233      context. By default, this is an empty dictionary. If a value in the 
     234      dictionary is callable, the generic view will call it 
     235      just before rendering the template. If it is not callable, it will be 
     236      evaluated once, at import time. Note that QuerySets are not callable, so 
     237      if you want to pass in a QuerySet in ``extra_context`` and have it 
     238      evaluated at render time, you need to wrap it in a function (that 
     239      returns the QuerySet). 
    232240 
    233241    * ``allow_empty``: A boolean specifying whether to display the page if no 
     
    288296      template. By default, it's ``django.template.loader``. 
    289297 
    290     * ``extra_context``: A dictionary of values to add to the template context. 
    291       If a value in the dictionary is callable, the generic view will call it 
    292       just before rendering the template. By default, this is an empty 
    293       dictionary. 
     298    * ``extra_context``: A dictionary of values to add to the template 
     299      context. By default, this is an empty dictionary. If a value in the 
     300      dictionary is callable, the generic view will call it 
     301      just before rendering the template. If it is not callable, it will be 
     302      evaluated once, at import time. Note that QuerySets are not callable, so 
     303      if you want to pass in a QuerySet in ``extra_context`` and have it 
     304      evaluated at render time, you need to wrap it in a function (that 
     305      returns the QuerySet). 
    294306 
    295307    * ``allow_empty``: A boolean specifying whether to display the page if no 
     
    361373      template. By default, it's ``django.template.loader``. 
    362374 
    363     * ``extra_context``: A dictionary of values to add to the template context. 
    364       If a value in the dictionary is callable, the generic view will call it 
    365       just before rendering the template. By default, this is an empty 
    366       dictionary. 
     375    * ``extra_context``: A dictionary of values to add to the template 
     376      context. By default, this is an empty dictionary. If a value in the 
     377      dictionary is callable, the generic view will call it 
     378      just before rendering the template. If it is not callable, it will be 
     379      evaluated once, at import time. Note that QuerySets are not callable, so 
     380      if you want to pass in a QuerySet in ``extra_context`` and have it 
     381      evaluated at render time, you need to wrap it in a function (that 
     382      returns the QuerySet). 
    367383 
    368384    * ``allow_empty``: A boolean specifying whether to display the page if no 
     
    437453      template. By default, it's ``django.template.loader``. 
    438454 
    439     * ``extra_context``: A dictionary of values to add to the template context. 
    440       If a value in the dictionary is callable, the generic view will call it 
    441       just before rendering the template. By default, this is an empty 
    442       dictionary. 
     455    * ``extra_context``: A dictionary of values to add to the template 
     456      context. By default, this is an empty dictionary. If a value in the 
     457      dictionary is callable, the generic view will call it 
     458      just before rendering the template. If it is not callable, it will be 
     459      evaluated once, at import time. Note that QuerySets are not callable, so 
     460      if you want to pass in a QuerySet in ``extra_context`` and have it 
     461      evaluated at render time, you need to wrap it in a function (that 
     462      returns the QuerySet). 
    443463 
    444464    * ``allow_empty``: A boolean specifying whether to display the page if no 
     
    544564      template. By default, it's ``django.template.loader``. 
    545565 
    546     * ``extra_context``: A dictionary of values to add to the template context. 
    547       If a value in the dictionary is callable, the generic view will call it 
    548       just before rendering the template. By default, this is an empty 
    549       dictionary. 
     566    * ``extra_context``: A dictionary of values to add to the template 
     567      context. By default, this is an empty dictionary. If a value in the 
     568      dictionary is callable, the generic view will call it 
     569      just before rendering the template. If it is not callable, it will be 
     570      evaluated once, at import time. Note that QuerySets are not callable, so 
     571      if you want to pass in a QuerySet in ``extra_context`` and have it 
     572      evaluated at render time, you need to wrap it in a function (that 
     573      returns the QuerySet). 
    550574 
    551575    * ``context_processors``: A list of template-context processors to apply to 
     
    601625      template. By default, it's ``django.template.loader``. 
    602626 
    603     * ``extra_context``: A dictionary of values to add to the template context. 
    604       If a value in the dictionary is callable, the generic view will call it 
    605       just before rendering the template. By default, this is an empty 
    606       dictionary. 
     627    * ``extra_context``: A dictionary of values to add to the template 
     628      context. By default, this is an empty dictionary. If a value in the 
     629      dictionary is callable, the generic view will call it 
     630      just before rendering the template. If it is not callable, it will be 
     631      evaluated once, at import time. Note that QuerySets are not callable, so 
     632      if you want to pass in a QuerySet in ``extra_context`` and have it 
     633      evaluated at render time, you need to wrap it in a function (that 
     634      returns the QuerySet). 
    607635 
    608636    * ``allow_empty``: A boolean specifying whether to display the page if no 
     
    698726      template. By default, it's ``django.template.loader``. 
    699727 
    700     * ``extra_context``: A dictionary of values to add to the template context. 
    701       If a value in the dictionary is callable, the generic view will call it 
    702       just before rendering the template. By default, this is an empty 
    703       dictionary. 
     728    * ``extra_context``: A dictionary of values to add to the template 
     729      context. By default, this is an empty dictionary. If a value in the 
     730      dictionary is callable, the generic view will call it 
     731      just before rendering the template. If it is not callable, it will be 
     732      evaluated once, at import time. Note that QuerySets are not callable, so 
     733      if you want to pass in a QuerySet in ``extra_context`` and have it 
     734      evaluated at render time, you need to wrap it in a function (that 
     735      returns the QuerySet). 
    704736 
    705737    * ``context_processors``: A list of template-context processors to apply to 
     
    765797      template. By default, it's ``django.template.loader``. 
    766798 
    767     * ``extra_context``: A dictionary of values to add to the template context. 
    768       If a value in the dictionary is callable, the generic view will call it 
    769       just before rendering the template. By default, this is an empty 
    770       dictionary. 
     799    * ``extra_context``: A dictionary of values to add to the template 
     800      context. By default, this is an empty dictionary. If a value in the 
     801      dictionary is callable, the generic view will call it 
     802      just before rendering the template. If it is not callable, it will be 
     803      evaluated once, at import time. Note that QuerySets are not callable, so 
     804      if you want to pass in a QuerySet in ``extra_context`` and have it 
     805      evaluated at render time, you need to wrap it in a function (that 
     806      returns the QuerySet). 
    771807 
    772808    * ``context_processors``: A list of template-context processors to apply to 
     
    844880      template. By default, it's ``django.template.loader``. 
    845881 
    846     * ``extra_context``: A dictionary of values to add to the template context. 
    847       If a value in the dictionary is callable, the generic view will call it 
    848       just before rendering the template. By default, this is an empty 
    849       dictionary. 
     882    * ``extra_context``: A dictionary of values to add to the template 
     883      context. By default, this is an empty dictionary. If a value in the 
     884      dictionary is callable, the generic view will call it 
     885      just before rendering the template. If it is not callable, it will be 
     886      evaluated once, at import time. Note that QuerySets are not callable, so 
     887      if you want to pass in a QuerySet in ``extra_context`` and have it 
     888      evaluated at render time, you need to wrap it in a function (that 
     889      returns the QuerySet). 
    850890 
    851891    * ``context_processors``: A list of template-context processors to apply to 
     
    925965      template. By default, it's ``django.template.loader``. 
    926966 
    927     * ``extra_context``: A dictionary of values to add to the template context. 
    928       If a value in the dictionary is callable, the generic view will call it 
    929       just before rendering the template. By default, this is an empty 
    930       dictionary. 
     967    * ``extra_context``: A dictionary of values to add to the template 
     968      context. By default, this is an empty dictionary. If a value in the 
     969      dictionary is callable, the generic view will call it 
     970      just before rendering the template. If it is not callable, it will be 
     971      evaluated once, at import time. Note that QuerySets are not callable, so 
     972      if you want to pass in a QuerySet in ``extra_context`` and have it 
     973      evaluated at render time, you need to wrap it in a function (that 
     974      returns the QuerySet). 
    931975 
    932976    * ``context_processors``: A list of template-context processors to apply to