Django

Code

Show
Ignore:
Timestamp:
08/05/08 12:15:33 (5 months ago)
Author:
jbronn
Message:

gis: Merged revisions 7981-8001,8003-8011,8013-8033,8035-8036,8038-8039,8041-8063,8065-8076,8078-8139,8141-8154,8156-8214 via svnmerge from trunk.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/gis

    • Property svnmerge-integrated changed from /django/trunk:1-7978 to /django/trunk:1-8214
  • django/branches/gis/docs/generic_views.txt

    r7979 r8215  
    8484-------------------------------------------------- 
    8585 
    86 **Description:** 
     86Description 
     87~~~~~~~~~~~ 
    8788 
    8889Renders a given template, passing it a ``{{ params }}`` template variable, 
    8990which is a dictionary of the parameters captured in the URL. 
    9091 
    91 **Required arguments:** 
    92  
    93     * ``template``: The full name of a template to use. 
    94  
    95 **Optional arguments:** 
    96  
    97     * ``extra_context``: A dictionary of values to add to the template 
    98       context. By default, this is an empty dictionary. If a value in the 
    99       dictionary is callable, the generic view will call it 
    100       just before rendering the template. 
    101  
    102     * ``mimetype``: The MIME type to use for the resulting document. Defaults 
    103       to the value of the ``DEFAULT_CONTENT_TYPE`` setting. 
     92Required arguments 
     93~~~~~~~~~~~~~~~~~~ 
     94 
     95``template`` 
     96    The full name of a template to use. 
     97 
     98Optional arguments 
     99~~~~~~~~~~~~~~~~~~ 
     100 
     101``extra_context`` 
     102    A dictionary of values to add to the template context. By default, this is 
     103    an empty dictionary. If a value in the dictionary is callable, the generic 
     104    view will call it just before rendering the template. 
     105 
     106``mimetype`` 
     107    The MIME type to use for the resulting document. Defaults to the value of 
     108    the ``DEFAULT_CONTENT_TYPE`` setting. 
    104109 
    105110**Example:** 
     
    119124------------------------------------------- 
    120125 
    121 **Description:** 
     126Description 
     127~~~~~~~~~~~ 
    122128 
    123129Redirects to a given URL. 
     
    128134If the given URL is ``None``, Django will return an ``HttpResponseGone`` (410). 
    129135 
    130 **Required arguments:** 
    131  
    132     * ``url``: The URL to redirect to, as a string. Or ``None`` to raise a 410 
    133       (Gone) HTTP error. 
     136Required arguments 
     137~~~~~~~~~~~~~~~~~~ 
     138 
     139``url`` 
     140    The URL to redirect to, as a string. Or ``None`` to raise a 410 (Gone) 
     141    HTTP error. 
    134142 
    135143**Example:** 
     
    156164------------------------------------------------- 
    157165 
    158 **Description:** 
     166Description 
     167~~~~~~~~~~~ 
    159168 
    160169A top-level index page showing the "latest" objects, by date. Objects with 
     
    162171``True``. 
    163172 
    164 **Required arguments:** 
    165  
    166     * ``queryset``: A ``QuerySet`` of objects for which the archive serves. 
    167  
    168     * ``date_field``: The name of the ``DateField`` or ``DateTimeField`` in 
    169       the ``QuerySet``'s model that the date-based archive should use to 
    170       determine the objects on the page. 
    171  
    172 **Optional arguments:** 
    173  
    174     * ``num_latest``: The number of latest objects to send to the template 
    175       context. By default, it's 15. 
    176  
    177     * ``template_name``: The full name of a template to use in rendering the 
    178       page. This lets you override the default template name (see below). 
    179  
    180     * ``template_loader``: The template loader to use when loading the 
    181       template. By default, it's ``django.template.loader``. 
    182  
    183     * ``extra_context``: A dictionary of values to add to the template 
    184       context. By default, this is an empty dictionary. If a value in the 
    185       dictionary is callable, the generic view will call it 
    186       just before rendering the template. 
    187  
    188     * ``allow_empty``: A boolean specifying whether to display the page if no 
    189       objects are available. If this is ``False`` and no objects are available, 
    190       the view will raise a 404 instead of displaying an empty page. By 
    191       default, this is ``True``. 
    192  
    193     * ``context_processors``: A list of template-context processors to apply to 
    194       the view's template. See the `RequestContext docs`_. 
    195  
    196     * ``mimetype``: The MIME type to use for the resulting document. Defaults 
    197       to the value of the ``DEFAULT_CONTENT_TYPE`` setting. 
    198  
    199     * ``allow_future``: A boolean specifying whether to include "future" 
    200       objects on this page, where "future" means objects in which the field 
    201       specified in ``date_field`` is greater than the current date/time. By 
    202       default, this is ``False``. 
    203  
    204     * **New in Django development version:** ``template_object_name``: 
    205       Designates the name of the template variable to use in the template 
    206       context. By default, this is ``'latest'``. 
    207  
    208 **Template name:** 
     173Required arguments 
     174~~~~~~~~~~~~~~~~~~ 
     175 
     176``queryset`` 
     177    A ``QuerySet`` of objects for which the archive serves. 
     178 
     179``date_field`` 
     180    The name of the ``DateField`` or ``DateTimeField`` in the ``QuerySet``'s 
     181    model that the date-based archive should use to determine the objects on 
     182    the page. 
     183 
     184Optional arguments 
     185~~~~~~~~~~~~~~~~~~ 
     186 
     187``num_latest`` 
     188    The number of latest objects to send to the template context. By default, 
     189    it's 15. 
     190 
     191``template_name`` 
     192    The full name of a template to use in rendering the page. This lets you 
     193    override the default template name (see below). 
     194 
     195``template_loader`` 
     196    The template loader to use when loading the template. By default, it's 
     197    ``django.template.loader``. 
     198 
     199``extra_context`` 
     200    A dictionary of values to add to the template context. By default, this is 
     201    an empty dictionary. If a value in the dictionary is callable, the generic 
     202    view will call it just before rendering the template. 
     203 
     204``allow_empty`` 
     205    A boolean specifying whether to display the page if no objects are 
     206    available. If this is ``False`` and no objects are available, the view will 
     207    raise a 404 instead of displaying an empty page. By default, this is 
     208    ``True``. 
     209 
     210``context_processors`` 
     211    A list of template-context processors to apply to the view's template. See 
     212    the `RequestContext docs`_. 
     213 
     214``mimetype`` 
     215    The MIME type to use for the resulting document. Defaults to the value of 
     216    the ``DEFAULT_CONTENT_TYPE`` setting. 
     217 
     218``allow_future`` 
     219    A boolean specifying whether to include "future" objects on this page, 
     220    where "future" means objects in which the field specified in ``date_field`` 
     221    is greater than the current date/time. By default, this is ``False``. 
     222 
     223``template_object_name`` (**New in Django development version**) 
     224    Designates the name of the template variable to use in the template 
     225    context. By default, this is ``'latest'``. 
     226 
     227Template name 
     228~~~~~~~~~~~~~ 
    209229 
    210230If ``template_name`` isn't specified, this view will use the template 
     
    218238      ``apps/blog/models.py``, that'd be ``blog``. 
    219239 
    220 **Template context:** 
     240Template context 
     241~~~~~~~~~~~~~~~~ 
    221242 
    222243In addition to ``extra_context``, the template's context will be: 
    223244 
    224     * ``date_list``: A list of ``datetime.date`` objects representing all 
    225       years that have objects available according to ``queryset``. These are 
    226       ordered in reverse. This is equivalent to 
    227       ``queryset.dates(date_field, 'year')[::-1]``. 
    228  
    229     * ``latest``: The ``num_latest`` objects in the system, ordered descending 
    230       by ``date_field``. For example, if ``num_latest`` is ``10``, then 
    231       ``latest`` will be a list of the latest 10 objects in ``queryset``. 
    232  
    233       **New in Django development version:** This variable's name depends on 
    234       the ``template_object_name`` parameter, which is ``'latest'`` by default. 
    235       If ``template_object_name`` is ``'foo'``, this variable's name will be 
    236       ``foo``. 
     245``date_list`` 
     246    A list of ``datetime.date`` objects representing all years that have 
     247    objects available according to ``queryset``. These are ordered in reverse. 
     248    This is equivalent to ``queryset.dates(date_field, 'year')[::-1]``. 
     249 
     250``latest`` 
     251    The ``num_latest`` objects in the system, ordered descending by 
     252    ``date_field``. For example, if ``num_latest`` is ``10``, then ``latest`` 
     253    will be a list of the latest 10 objects in ``queryset``. 
     254 
     255    **New in Django development version:** This variable's name depends on the 
     256    ``template_object_name`` parameter, which is ``'latest'`` by default. 
     257    If ``template_object_name`` is ``'foo'``, this variable's name will be 
     258    ``foo``. 
    237259 
    238260.. _RequestContext docs: ../templates_python/#subclassing-context-requestcontext 
     
    241263------------------------------------------------ 
    242264 
    243 **Description:** 
     265Description 
     266~~~~~~~~~~~ 
    244267 
    245268A yearly archive page showing all available months in a given year. Objects 
     
    247270to ``True``. 
    248271 
    249 **Required arguments:** 
    250  
    251     * ``year``: The four-digit year for which the archive serves. 
    252  
    253     * ``queryset``: A ``QuerySet`` of objects for which the archive serves. 
    254  
    255     * ``date_field``: The name of the ``DateField`` or ``DateTimeField`` in 
    256       the ``QuerySet``'s model that the date-based archive should use to 
    257       determine the objects on the page. 
    258  
    259 **Optional arguments:** 
    260  
    261     * ``template_name``: The full name of a template to use in rendering the 
    262       page. This lets you override the default template name (see below). 
    263  
    264     * ``template_loader``: The template loader to use when loading the 
    265       template. By default, it's ``django.template.loader``. 
    266  
    267     * ``extra_context``: A dictionary of values to add to the template 
    268       context. By default, this is an empty dictionary. If a value in the 
    269       dictionary is callable, the generic view will call it 
    270       just before rendering the template. 
    271  
    272     * ``allow_empty``: A boolean specifying whether to display the page if no 
    273       objects are available. If this is ``False`` and no objects are available, 
    274       the view will raise a 404 instead of displaying an empty page. By 
    275       default, this is ``False``. 
    276  
    277     * ``context_processors``: A list of template-context processors to apply to 
    278       the view's template. See the `RequestContext docs`_. 
    279  
    280     * ``template_object_name``:  Designates the name of the template variable 
    281       to use in the template context. By default, this is ``'object'``. The 
    282       view will append ``'_list'`` to the value of this parameter in 
    283       determining the variable's name. 
    284  
    285     * ``make_object_list``: A boolean specifying whether to retrieve the full 
    286       list of objects for this year and pass those to the template. If ``True``, 
    287       this list of objects will be made available to the template as 
    288       ``object_list``. (The name ``object_list`` may be different; see the docs 
    289       for ``object_list`` in the "Template context" section below.) By default, 
    290       this is ``False``. 
    291  
    292     * ``mimetype``: The MIME type to use for the resulting document. Defaults 
    293       to the value of the ``DEFAULT_CONTENT_TYPE`` setting. 
    294  
    295     * ``allow_future``: A boolean specifying whether to include "future" 
    296       objects on this page, where "future" means objects in which the field 
    297       specified in ``date_field`` is greater than the current date/time. By 
    298       default, this is ``False``. 
    299  
    300 **Template name:** 
     272Required arguments 
     273~~~~~~~~~~~~~~~~~~ 
     274 
     275``year`` 
     276    The four-digit year for which the archive serves. 
     277 
     278``queryset`` 
     279    A ``QuerySet`` of objects for which the archive serves. 
     280 
     281``date_field`` 
     282    The name of the ``DateField`` or ``DateTimeField`` in the ``QuerySet``'s 
     283    model that the date-based archive should use to determine the objects on 
     284    the page. 
     285 
     286Optional arguments 
     287~~~~~~~~~~~~~~~~~~ 
     288 
     289``template_name`` 
     290    The full name of a template to use in rendering the page. This lets you 
     291    override the default template name (see below). 
     292 
     293``template_loader`` 
     294    The template loader to use when loading the template. By default, it's 
     295    ``django.template.loader``. 
     296 
     297``extra_context`` 
     298    A dictionary of values to add to the template context. By default, this is 
     299    an empty dictionary. If a value in the dictionary is callable, the generic 
     300    view will call it just before rendering the template. 
     301 
     302``allow_empty`` 
     303    A boolean specifying whether to display the page if no objects are 
     304    available. If this is ``False`` and no objects are available, the view will 
     305    raise a 404 instead of displaying an empty page. By default, this is 
     306    ``False``. 
     307 
     308``context_processors`` 
     309    A list of template-context processors to apply to the view's template. See 
     310    the `RequestContext docs`_. 
     311 
     312``template_object_name`` 
     313    Designates the name of the template variable to use in the template 
     314    context. By default, this is ``'object'``. The view will append ``'_list'`` 
     315    to the value of this parameter in determining the variable's name. 
     316 
     317``make_object_list`` 
     318    A boolean specifying whether to retrieve the full  list of objects for this 
     319    year and pass those to the template. If ``True``, this list of objects will 
     320    be made available to the template as ``object_list``. (The name 
     321    ``object_list`` may be different; see the docs for ``object_list`` in the 
     322    "Template context" section below.) By default, this is ``False``. 
     323 
     324``mimetype`` 
     325    The MIME type to use for the resulting document. Defaults to the value of 
     326    the ``DEFAULT_CONTENT_TYPE`` setting. 
     327 
     328``allow_future`` 
     329    A boolean specifying whether to include "future" objects on this page, 
     330    where "future" means objects in which the field specified in ``date_field`` 
     331    is greater than the current date/time. By default, this is ``False``. 
     332 
     333Template name 
     334~~~~~~~~~~~~~ 
    301335 
    302336If ``template_name`` isn't specified, this view will use the template 
    303337``<app_label>/<model_name>_archive_year.html`` by default. 
    304338 
    305 **Template context:** 
     339Template context 
     340~~~~~~~~~~~~~~~~ 
    306341 
    307342In addition to ``extra_context``, the template's context will be: 
    308343 
    309     * ``date_list``: A list of ``datetime.date`` objects representing all 
    310       months that have objects available in the given year, according to 
    311       ``queryset``, in ascending order. 
    312  
    313     * ``year``: The given year, as a four-character string. 
    314  
    315     * ``object_list``: If the ``make_object_list`` parameter is ``True``, this 
    316       will be set to a list of objects available for the given year, ordered by 
    317       the date field. This variable's name depends on the 
    318       ``template_object_name`` parameter, which is ``'object'`` by default. If 
    319       ``template_object_name`` is ``'foo'``, this variable's name will be 
    320       ``foo_list``. 
    321  
    322       If ``make_object_list`` is ``False``, ``object_list`` will be passed to 
    323       the template as an empty list. 
     344``date_list`` 
     345    A list of ``datetime.date`` objects representing all months that have 
     346    objects available in the given year, according to ``queryset``, in 
     347    ascending order. 
     348 
     349``year`` 
     350    The given year, as a four-character string. 
     351 
     352``object_list`` 
     353    If the ``make_object_list`` parameter is ``True``, this will be set to a 
     354    list of objects available for the given year, ordered by the date field. 
     355    This variable's name depends on the ``template_object_name`` parameter, 
     356    which is ``'object'`` by default. If ``template_object_name`` is ``'foo'``, 
     357    this variable's name will be ``foo_list``. 
     358 
     359    If ``make_object_list`` is ``False``, ``object_list`` will be passed to the 
     360    template as an empty list. 
    324361 
    325362``django.views.generic.date_based.archive_month`` 
    326363------------------------------------------------- 
    327364 
    328 **Description:** 
     365Description 
     366~~~~~~~~~~~ 
    329367 
    330368A monthly archive page showing all objects in a given month. Objects with a 
     
    332370``True``. 
    333371 
    334 **Required arguments:** 
    335  
    336     * ``year``: The four-digit year for which the archive serves (a string). 
    337  
    338     * ``month``: The month for which the archive serves, formatted according to 
    339       the ``month_format`` argument. 
    340  
    341     * ``queryset``: A ``QuerySet`` of objects for which the archive serves. 
    342  
    343     * ``date_field``: The name of the ``DateField`` or ``DateTimeField`` in 
    344       the ``QuerySet``'s model that the date-based archive should use to 
    345       determine the objects on the page. 
    346  
    347 **Optional arguments:** 
    348  
    349     * ``month_format``: A format string that regulates what format the 
    350       ``month`` parameter uses. This should be in the syntax accepted by 
    351       Python's ``time.strftime``. (See the `strftime docs`_.) It's set to 
    352       ``"%b"`` by default, which is a three-letter month abbreviation. To 
    353       change it to use numbers, use ``"%m"``. 
    354  
    355     * ``template_name``: The full name of a template to use in rendering the 
    356       page. This lets you override the default template name (see below). 
    357  
    358     * ``template_loader``: The template loader to use when loading the 
    359       template. By default, it's ``django.template.loader``. 
    360  
    361     * ``extra_context``: A dictionary of values to add to the template 
    362       context. By default, this is an empty dictionary. If a value in the 
    363       dictionary is callable, the generic view will call it 
    364       just before rendering the template. 
    365  
    366     * ``allow_empty``: A boolean specifying whether to display the page if no 
    367       objects are available. If this is ``False`` and no objects are available, 
    368       the view will raise a 404 instead of displaying an empty page. By 
    369       default, this is ``False``. 
    370  
    371     * ``context_processors``: A list of template-context processors to apply to 
    372       the view's template. See the `RequestContext docs`_. 
    373  
    374     * ``template_object_name``:  Designates the name of the template variable 
    375       to use in the template context. By default, this is ``'object'``. The 
    376       view will append ``'_list'`` to the value of this parameter in 
    377       determining the variable's name. 
    378  
    379     * ``mimetype``: The MIME type to use for the resulting document. Defaults 
    380       to the value of the ``DEFAULT_CONTENT_TYPE`` setting. 
    381  
    382     * ``allow_future``: A boolean specifying whether to include "future" 
    383       objects on this page, where "future" means objects in which the field 
    384       specified in ``date_field`` is greater than the current date/time. By 
    385       default, this is ``False``. 
    386  
    387 **Template name:** 
     372Required arguments 
     373~~~~~~~~~~~~~~~~~~ 
     374 
     375``year`` 
     376    The four-digit year for which the archive serves (a string). 
     377 
     378``month`` 
     379    The month for which the archive serves, formatted according to the 
     380    ``month_format`` argument. 
     381 
     382``queryset`` 
     383    A ``QuerySet`` of objects for which the archive serves. 
     384 
     385``date_field`` 
     386    The name of the ``DateField`` or ``DateTimeField`` in the ``QuerySet``'s 
     387    model that the date-based archive should use to determine the objects on 
     388    the page. 
     389 
     390Optional arguments 
     391~~~~~~~~~~~~~~~~~~ 
     392 
     393``month_format`` 
     394    A format string that regulates what format the ``month`` parameter uses. 
     395    This should be in the syntax accepted by Python's ``time.strftime``. (See 
     396    the `strftime docs`_.) It's set to ``"%b"`` by default, which is a three- 
     397    letter month abbreviation. To change it to use numbers, use ``"%m"``. 
     398 
     399``template_name`` 
     400    The full name of a template to use in rendering the page. This lets you 
     401    override the default template name (see below). 
     402 
     403``template_loader`` 
     404    The template loader to use when loading the template. By default, it's 
     405    ``django.template.loader``. 
     406 
     407``extra_context`` 
     408    A dictionary of values to add to the template context. By default, this is 
     409    an empty dictionary. If a value in the dictionary is callable, the generic 
     410    view will call it just before rendering the template. 
     411 
     412``allow_empty`` 
     413    A boolean specifying whether to display the page if no objects are 
     414    available. If this is ``False`` and no objects are available, the view will 
     415    raise a 404 instead of displaying an empty page. By default, this is 
     416    ``False``. 
     417 
     418``context_processors`` 
     419    A list of template-context processors to apply to the view's template. See 
     420    the `RequestContext docs`_. 
     421 
     422``template_object_name`` 
     423    Designates the name of the template variable to use in the template 
     424    context. By default, this is ``'object'``. The view will append ``'_list'`` 
     425    to the value of this parameter in determining the variable's name. 
     426 
     427``mimetype`` 
     428    The MIME type to use for the resulting document. Defaults to the value of 
     429    the ``DEFAULT_CONTENT_TYPE`` setting. 
     430 
     431``allow_future`` 
     432    A boolean specifying whether to include "future" objects on this page, 
     433    where "future" means objects in which the field specified in ``date_field`` 
     434    is greater than the current date/time. By default, this is ``False``. 
     435 
     436Template name 
     437~~~~~~~~~~~~~ 
    388438 
    389439If ``template_name`` isn't specified, this view will use the template 
    390440``<app_label>/<model_name>_archive_month.html`` by default. 
    391441 
    392 **Template context:** 
     442Template context 
     443~~~~~~~~~~~~~~~~ 
    393444 
    394445In addition to ``extra_context``, the template's context will be: 
    395446 
    396     * ``month``: A ``datetime.date`` object representing the given month. 
    397  
    398     * ``next_month``: A ``datetime.date`` object representing the first day of 
    399       the next month. If the next month is in the future, this will be 
    400       ``None``. 
    401  
    402     * ``previous_month``: A ``datetime.date`` object representing the first day 
    403       of the previous month. Unlike ``next_month``, this will never be 
    404       ``None``. 
    405  
    406     * ``object_list``: A list of objects available for the given month. This 
    407       variable's name depends on the ``template_object_name`` parameter, which 
    408       is ``'object'`` by default. If ``template_object_name`` is ``'foo'``, 
    409       this variable's name will be ``foo_list``. 
     447``month`` 
     448    A ``datetime.date`` object representing the given month. 
     449 
     450``next_month`` 
     451    A ``datetime.date`` object representing the first day of the next month. If 
     452     the next month is in the future, this will be ``None``. 
     453 
     454``previous_month`` 
     455    A ``datetime.date`` object representing the first day of the previous 
     456    month. Unlike ``next_month``, this will never be ``None``. 
     457 
     458``object_list`` 
     459    A list of objects available for the given month. This variable's name 
     460    depends on the ``template_object_name`` parameter, which is ``'object'`` by 
     461    default. If ``template_object_name`` is ``'foo'``, this variable's name 
     462    will be ``foo_list``. 
    410463 
    411464.. _strftime docs: http://www.python.org/doc/current/lib/module-time.html#l2h-1941 
     
    414467------------------------------------------------ 
    415468 
    416 **Description:** 
     469Description 
     470~~~~~~~~~~~ 
    417471 
    418472A weekly archive page showing all objects in a given week. Objects with a date 
    419473in the *future* are not displayed unless you set ``allow_future`` to ``True``. 
    420474 
    421 **Required arguments:** 
    422  
    423     * ``year``: The four-digit year for which the archive serves (a string). 
    424  
    425     * ``week``: The week of the year for which the archive serves (a string). 
    426       Weeks start with Sunday. 
    427  
    428     * ``queryset``: A ``QuerySet`` of objects for which the archive serves. 
    429  
    430     * ``date_field``: The name of the ``DateField`` or ``DateTimeField`` in 
    431       the ``QuerySet``'s model that the date-based archive should use to 
    432       determine the objects on the page. 
    433  
    434 **Optional arguments:** 
    435  
    436     * ``template_name``: The full name of a template to use in rendering the 
    437       page. This lets you override the default template name (see below). 
    438  
    439     * ``template_loader``: The template loader to use when loading the 
    440       template. By default, it's ``django.template.loader``. 
    441  
    442     * ``extra_context``: A dictionary of values to add to the template 
    443       context. By default, this is an empty dictionary. If a value in the 
    444       dictionary is callable, the generic view will call it 
    445       just before rendering the template. 
    446  
    447     * ``allow_empty``: A boolean specifying whether to display the page if no 
    448       objects are available. If this is ``False`` and no objects are available, 
    449       the view will raise a 404 instead of displaying an empty page. By 
    450       default, this is ``True``. 
    451  
    452     * ``context_processors``: A list of template-context processors to apply to 
    453       the view's template. See the `RequestContext docs`_. 
    454  
    455     * ``template_object_name``:  Designates the name of the template variable 
    456       to use in the template context. By default, this is ``'object'``. The 
    457       view will append ``'_list'`` to the value of this parameter in 
    458       determining the variable's name. 
    459  
    460     * ``mimetype``: The MIME type to use for the resulting document. Defaults 
    461       to the value of the ``DEFAULT_CONTENT_TYPE`` setting. 
    462  
    463     * ``allow_future``: A boolean specifying whether to include "future" 
    464       objects on this page, where "future" means objects in which the field 
    465       specified in ``date_field`` is greater than the current date/time. By 
    466       default, this is ``False``. 
    467  
    468 **Template name:** 
     475Required arguments 
     476~~~~~~~~~~~~~~~~~~ 
     477 
     478``year`` 
     479    The four-digit year for which the archive serves (a string). 
     480 
     481``week`` 
     482    The week of the year for which the archive serves (a string). Weeks start 
     483    with Sunday. 
     484 
     485``queryset`` 
     486    A ``QuerySet`` of objects for which the archive serves. 
     487 
     488``date_field`` 
     489    The name of the ``DateField`` or ``DateTimeField`` in the ``QuerySet``'s 
     490    model that the date-based archive should use to determine the objects on 
     491    the page. 
     492 
     493Optional arguments 
     494~~~~~~~~~~~~~~~~~~ 
     495 
     496``template_name`` 
     497    The full name of a template to use in rendering the page. This lets you 
     498    override the default template name (see below). 
     499 
     500``template_loader`` 
     501    The template loader to use when loading the template. By default, it's 
     502    ``django.template.loader``. 
     503 
     504``extra_context`` 
     505    A dictionary of values to add to the template context. By default, this is 
     506    an empty dictionary. If a value in the dictionary is callable, the generic 
     507    view will call it just before rendering the template. 
     508 
     509``allow_empty`` 
     510    A boolean specifying whether to display the page if no objects are 
     511    available. If this is ``False`` and no objects are available, the view will 
     512    raise a 404 instead of displaying an empty page. By default, this is 
     513    ``True``. 
     514 
     515``context_processors`` 
     516    A list of template-context processors to apply to the view's template. See 
     517    the `RequestContext docs`_. 
     518 
     519``template_object_name`` 
     520    Designates the name of the template variable to use in the template 
     521    context. By default, this is ``'object'``. The view will append ``'_list'`` 
     522    to the value of this parameter in determining the variable's name. 
     523 
     524``mimetype`` 
     525    The MIME type to use for the resulting document. Defaults to the value of 
     526    the ``DEFAULT_CONTENT_TYPE`` setting. 
     527 
     528``allow_future`` 
     529    A boolean specifying whether to include "future" objects on this page, 
     530    where "future" means objects in which the field specified in ``date_field`` 
     531    is greater than the current date/time. By default, this is ``False``. 
     532 
     533Template name 
     534~~~~~~~~~~~~~ 
    469535 
    470536If ``template_name`` isn't specified, this view will use the template 
    471537``<app_label>/<model_name>_archive_week.html`` by default. 
    472538 
    473 **Template context:** 
     539Template context 
     540~~~~~~~~~~~~~~~~ 
    474541 
    475542In addition to ``extra_context``, the template's context will be: 
    476543 
    477     * ``week``: A ``datetime.date`` object representing the first day of the 
    478       given week. 
    479  
    480     * ``object_list``: A list of objects available for the given week. This 
    481       variable's name depends on the ``template_object_name`` parameter, which 
    482       is ``'object'`` by default. If ``template_object_name`` is ``'foo'``, 
    483       this variable's name will be ``foo_list``. 
     544``week`` 
     545    A ``datetime.date`` object representing the first day of the given week. 
     546 
     547``object_list`` 
     548    A list of objects available for the given week. This variable's name 
     549    depends on the ``template_object_name`` parameter, which is ``'object'`` by 
     550    default. If ``template_object_name`` is ``'foo'``, this variable's name 
     551    will be ``foo_list``. 
    484552 
    485553``django.views.generic.date_based.archive_day`` 
    486554----------------------------------------------- 
    487555 
    488 **Description:** 
     556Description 
     557~~~~~~~~~~~ 
    489558 
    490559A day archive page showing all objects in a given day. Days in the future throw 
     
    492561you set ``allow_future`` to ``True``. 
    493562 
    494 **Required arguments:** 
    495  
    496     * ``year``: The four-digit year for which the archive serves (a string). 
    497  
    498     * ``month``: The month for which the archive serves, formatted according to 
    499       the ``month_format`` argument. 
    500  
    501     * ``day``: The day for which the archive serves, formatted according to the 
    502       ``day_format`` argument. 
    503  
    504     * ``queryset``: A ``QuerySet`` of objects for which the archive serves. 
    505  
    506     * ``date_field``: The name of the ``DateField`` or ``DateTimeField`` in 
    507       the ``QuerySet``'s model that the date-based archive should use to 
    508       determine the objects on the page. 
    509  
    510 **Optional arguments:** 
    511  
    512     * ``month_format``: A format string that regulates what format the 
    513       ``month`` parameter uses. This should be in the syntax accepted by 
    514       Python's ``time.strftime``. (See the `strftime docs`_.) It's set to 
    515       ``"%b"`` by default, which is a three-letter month abbreviation. To 
    516       change it to use numbers, use ``"%m"``. 
    517  
    518     * ``day_format``: Like ``month_format``, but for the ``day`` parameter. 
    519       It defaults to ``"%d"`` (day of the month as a decimal number, 01-31). 
    520  
    521     * ``template_name``: The full name of a template to use in rendering the 
    522       page. This lets you override the default template name (see below). 
    523  
    524     * ``template_loader``: The template loader to use when loading the 
    525       template. By default, it's ``django.template.loader``. 
    526  
    527     * ``extra_context``: A dictionary of values to add to the template 
    528       context. By default, this is an empty dictionary. If a value in the 
    529       dictionary is callable, the generic view will call it 
    530       just before rendering the template. 
    531  
    532     * ``allow_empty``: A boolean specifying whether to display the page if no 
    533       objects are available. If this is ``False`` and no objects are available, 
    534       the view will raise a 404 instead of displaying an empty page. By 
    535       default, this is ``False``. 
    536  
    537     * ``context_processors``: A list of template-context processors to apply to 
    538       the view's template. See the `RequestContext docs`_. 
    539  
    540     * ``template_object_name``:  Designates the name of the template variable 
    541       to use in the template context. By default, this is ``'object'``. The 
    542       view will append ``'_list'`` to the value of this parameter in 
    543       determining the variable's name. 
    544  
    545     * ``mimetype``: The MIME type to use for the resulting document. Defaults 
    546       to the value of the ``DEFAULT_CONTENT_TYPE`` setting. 
    547  
    548     * ``allow_future``: A boolean specifying whether to include "future" 
    549       objects on this page, where "future" means objects in which the field 
    550       specified in ``date_field`` is greater than the current date/time. By 
    551       default, this is ``False``. 
    552  
    553 **Template name:** 
     563Required arguments 
     564~~~~~~~~~~~~~~~~~~ 
     565 
     566``year`` 
     567    The four-digit year for which the archive serves (a string). 
     568 
     569``month`` 
     570    The month for which the archive serves, formatted according to the 
     571    ``month_format`` argument. 
     572 
     573``day`` 
     574    The day for which the archive serves, formatted according to the 
     575    ``day_format`` argument. 
     576 
     577``queryset`` 
     578    A ``QuerySet`` of objects for which the archive serves. 
     579 
     580``date_field`` 
     581    The name of the ``DateField`` or ``DateTimeField`` in the ``QuerySet``'s 
     582    model that the date-based archive should use to determine the objects on 
     583    the page. 
     584 
     585Optional arguments 
     586~~~~~~~~~~~~~~~~~~ 
     587 
     588``month_format`` 
     589    A format string that regulates what format the ``month`` parameter uses. 
     590    This should be in the syntax accepted by Python's ``time.strftime``. (See 
     591    the `strftime docs`_.) It's set to ``"%b"`` by default, which is a three- 
     592    letter month abbreviation. To change it to use numbers, use ``"%m"``. 
     593 
     594``day_format`` 
     595    Like ``month_format``, but for the ``day`` parameter. It defaults to 
     596    ``"%d"`` (day of the month as a decimal number, 01-31). 
     597 
     598``template_name`` 
     599    The full name of a template to use in rendering the page. This lets you 
     600    override the default template name (see below). 
     601 
     602``template_loader`` 
     603    The template loader to use when loading the template. By default, it's 
     604    ``django.template.loader``. 
     605 
     606``extra_context`` 
     607    A dictionary of values to add to the template context. By default, this is 
     608    an empty dictionary. If a value in the dictionary is callable, the generic 
     609    view will call it just before rendering the template. 
     610 
     611``allow_empty`` 
     612    A boolean specifying whether to display the page if no objects are 
     613    available. If this is ``False`` and no objects are available, the view will 
     614    raise a 404 instead of displaying an empty page. By default, this is 
     615    ``False``. 
     616 
     617``context_processors`` 
     618    A list of template-context processors to apply to the view's template. See 
     619    the `RequestContext docs`_. 
     620 
     621``template_object_name`` 
     622     Designates the name of the template variable to use in the template 
     623     context. By default, this is ``'object'``. The view will append 
     624     ``'_list'`` to the value of this parameter in determining the variable's 
     625     name. 
     626 
     627``mimetype`` 
     628    The MIME type to use for the resulting document. Defaults to the value of 
     629    the ``DEFAULT_CONTENT_TYPE`` setting. 
     630 
     631``allow_future`` 
     632    A boolean specifying whether to include "future" objects on this page, 
     633    where "future" means objects in which the field specified in ``date_field`` 
     634    is greater than the current date/time. By default, this is ``False``. 
     635 
     636Template name 
     637~~~~~~~~~~~~~ 
    554638 
    555639If ``template_name`` isn't specified, this view will use the template 
    556640``<app_label>/<model_name>_archive_day.html`` by default. 
    557641 
    558 **Template context:** 
     642Template context 
     643~~~~~~~~~~~~~~~~ 
    559644 
    560645In addition to ``extra_context``, the template's context will be: 
    561646 
    562     * ``day``: A ``datetime.date`` object representing the given day. 
    563  
    564     * ``next_day``: A ``datetime.date`` object representing the next day. If 
    565       the next day is in the future, this will be ``None``. 
    566  
    567     * ``previous_day``: A ``datetime.date`` object representing the given day. 
    568       Unlike ``next_day``, this will never be ``None``. 
    569  
    570     * ``object_list``: A list of objects available for the given day. This 
    571       variable's name depends on the ``template_object_name`` parameter, which 
    572       is ``'object'`` by default. If ``template_object_name`` is ``'foo'``, 
    573       this variable's name will be ``foo_list``. 
     647``day`` 
     648    A ``datetime.date`` object representing the given day. 
     649 
     650``next_day`` 
     651    A ``datetime.date`` object representing the next day. If the next day is in 
     652    the future, this will be ``None``. 
     653 
     654``previous_day`` 
     655    A ``datetime.date`` object representing the given day. Unlike ``next_day``, 
     656    this will never be ``None``. 
     657 
     658``object_list`` 
     659    A list of objects available for the given day. This variable's name depends 
     660    on the ``template_object_name`` parameter, which is ``'object'`` by 
     661    default. If ``template_object_name`` is ``'foo'``, this variable's name 
     662    will be ``foo_list``. 
    574663 
    575664``django.views.generic.date_based.archive_today`` 
    576665------------------------------------------------- 
    577666 
    578 **Description:** 
     667Description 
     668~~~~~~~~~~~ 
    579669 
    580670A day archive page showing all objects for *today*. This is exactly the same as 
     
    585675------------------------------------------------- 
    586676 
    587 **Description:** 
     677Description 
     678~~~~~~~~~~~ 
    588679 
    589680A page representing an individual object. If the object has a date value in the 
     
    591682``allow_future`` to ``True``. 
    592683 
    593 **Required arguments:** 
    594  
    595     * ``year``: The object's four-digit year (a string). 
    596  
    597     * ``month``: The object's month , formatted according to the 
    598       ``month_format`` argument. 
    599  
    600     * ``day``: The object's day , formatted according to the ``day_format`` 
    601       argument. 
    602  
    603     * ``queryset``: A ``QuerySet`` that contains the object. 
    604  
    605     * ``date_field``: The name of the ``DateField`` or ``DateTimeField`` in 
    606       the ``QuerySet``'s model that the generic view should use to look up the 
    607       object according to ``year``, ``month`` and ``day``. 
    608  
    609     * Either ``object_id`` or (``slug`` *and* ``slug_field``) is required. 
    610  
    611       If you provide ``object_id``, it should be the value of the primary-key 
    612       field for the object being displayed on this page. 
    613  
    614       Otherwise, ``slug`` should be the slug of the given object, and 
    615       ``slug_field`` should be the name of the slug field in the ``QuerySet``'s 
    616       model. By default, ``slug_field`` is ``'slug'``. 
    617  
    618 **Optional arguments:** 
    619  
    620     * ``month_format``: A format string that regulates what format the 
    621       ``month`` parameter uses. This should be in the syntax accepted by 
    622       Python's ``time.strftime``. (See the `strftime docs`_.) It's set to 
    623       ``"%b"`` by default, which is a three-letter month abbreviation. To 
    624       change it to use numbers, use ``"%m"``. 
    625  
    626     * ``day_format``: Like ``month_format``, but for the ``day`` parameter. 
    627       It defaults to ``"%d"`` (day of the month as a decimal number, 01-31). 
    628  
    629     * ``template_name``: The full name of a template to use in rendering the 
    630       page. This lets you override the default template name (see below). 
    631  
    632     * ``template_name_field``: The name of a field on the object whose value is 
    633       the template name to use. This lets you store template names in the data. 
    634       In other words, if your object has a field ``'the_template'`` that 
    635       contains a string ``'foo.html'``, and you set ``template_name_field`` to 
    636       ``'the_template'``, then the generic view for this object will use the 
    637       template ``'foo.html'``. 
    638  
    639       It's a bit of a brain-bender, but it's useful in some cases. 
    640  
    641     * ``template_loader``: The template loader to use when loading the 
    642       template. By default, it's ``django.template.loader``. 
    643  
    644     * ``extra_context``: A dictionary of values to add to the template 
    645       context. By default, this is an empty dictionary. If a value in the 
    646       dictionary is callable, the generic view will call it 
    647       just before rendering the template. 
    648  
    649     * ``context_processors``: A list of template-context processors to apply to 
    650       the view's template. See the `RequestContext docs`_. 
    651  
    652     * ``template_object_name``:  Designates the name of the template variable 
    653       to use in the template context. By default, this is ``'object'``. 
    654  
    655     * ``mimetype``: The MIME type to use for the resulting document. Defaults 
    656       to the value of the ``DEFAULT_CONTENT_TYPE`` setting. 
    657  
    658     * ``allow_future``: A boolean specifying whether to include "future" 
    659       objects on this page, where "future" means objects in which the field 
    660       specified in ``date_field`` is greater than the current date/time. By 
    661       default, this is ``False``. 
    662  
    663 **Template name:** 
     684Required arguments 
     685~~~~~~~~~~~~~~~~~~ 
     686 
     687``year`` 
     688    The object's four-digit year (a string). 
     689 
     690``month`` 
     691    The object's month , formatted according to the ``month_format`` argument. 
     692 
     693``day`` 
     694    The object's day , formatted according to the ``day_format`` argument. 
     695 
     696``queryset`` 
     697    A ``QuerySet`` that contains the object. 
     698 
     699``date_field`` 
     700    The name of the ``DateField`` or ``DateTimeField`` in the ``QuerySet``'s 
     701    model that the generic view should use to look up the object according to 
     702    ``year``, ``month`` and ``day``. 
     703 
     704Either ``object_id`` or (``slug`` *and* ``slug_field``) is required. 
     705    If you provide ``object_id``, it should be the value of the primary-key 
     706    field for the object being displayed on this page. 
     707 
     708    Otherwise, ``slug`` should be the slug of the given object, and 
     709    ``slug_field`` should be the name of the slug field in the ``QuerySet``'s 
     710    model. By default, ``slug_field`` is ``'slug'``. 
     711 
     712Optional arguments 
     713~~~~~~~~~~~~~~~~~~ 
     714 
     715``month_format`` 
     716    A format string that regulates what format the ``month`` parameter uses. 
     717    This should be in the syntax accepted by Python's ``time.strftime``. (See 
     718    the `strftime docs`_.) It's set to ``"%b"`` by default, which is a three- 
     719    letter month abbreviation. To change it to use numbers, use ``"%m"``. 
     720 
     721``day_format`` 
     722    Like ``month_format``, but for the ``day`` parameter. It defaults to 
     723    ``"%d"`` (day of the month as a decimal number, 01-31). 
     724 
     725``template_name`` 
     726    The full name of a template to use in rendering the page. This lets you 
     727    override the default template name (see below). 
     728 
     729``template_name_field`` 
     730    The name of a field on the object whose value is the template name to use. 
     731    This lets you store template names in the data. In other words, if your 
     732    object has a field ``'the_template'`` that contains a string 
     733    ``'foo.html'``, and you set ``template_name_field`` to ``'the_template'``, 
     734    then the generic view for this object will use the template ``'foo.html'``. 
     735 
     736    It's a bit of a brain-bender, but it's useful in some cases. 
     737 
     738``template_loader`` 
     739    The template loader to use when loading the  template. By default, it's 
     740    ``django.template.loader``. 
     741 
     742``extra_context`` 
     743    A dictionary of values to add to the template context. By default, this is 
     744    an empty dictionary. If a value in the dictionary is callable, the generic 
     745    view will call it just before rendering the template. 
     746 
     747``context_processors`` 
     748    A list of template-context processors to apply to the view's template. See 
     749    the `RequestContext docs`_. 
     750 
     751``template_object_name`` 
     752    Designates the name of the template variable to use in the template 
     753    context. By default, this is ``'object'``. 
     754 
     755``mimetype`` 
     756    The MIME type to use for the resulting document. Defaults to the value of 
     757    the ``DEFAULT_CONTENT_TYPE`` setting. 
     758 
     759``allow_future`` 
     760    A boolean specifying whether to include "future" objects on this page, 
     761    where "future" means objects in which the field specified in ``date_field`` 
     762    is greater than the current date/time. By default, this is ``False``. 
     763 
     764Template name 
     765~~~~~~~~~~~~~ 
    664766 
    665767If ``template_name`` isn't specified, this view will use the template 
    666768``<app_label>/<model_name>_detail.html`` by default. 
    667769 
    668 **Template context:** 
     770Template context 
     771~~~~~~~~~~~~~~~~ 
    669772 
    670773In addition to ``extra_context``, the template's context will be: 
    671774 
    672     * ``object``: The object. This variable's name depends on the 
    673       ``template_object_name`` parameter, which is ``'object'`` by default. If 
    674       ``template_object_name`` is ``'foo'``, this variable's name will be 
    675     ``foo``. 
     775``object`` 
     776    The object. This variable's name depends on the ``template_object_name`` 
     777    parameter, which is ``'object'`` by default. If ``template_object_name`` is 
     778    ``'foo'``, this variable's name will be ``foo``. 
    676779 
    677780List/detail generic views 
     
    686789------------------------------------------------ 
    687790 
    688 **Description:** 
     791Description 
     792~~~~~~~~~~~ 
    689793 
    690794A page representing a list of objects. 
    691795 
    692 **Required arguments:** 
    693  
    694     * ``queryset``: A ``QuerySet`` that represents the objects. 
    695  
    696 **Optional arguments:** 
    697  
    698     * ``paginate_by``: An integer specifying how many objects should be 
    699       displayed per page. If this is given, the view will paginate objects with 
    700       ``paginate_by`` objects per page. The view will expect either a ``page`` 
    701       query string parameter (via ``GET``) or a ``page`` variable specified in 
    702