mirror of https://github.com/django/django.git
Fixed #22167 -- Improved documentation on context processors
Clarified the explanation on the order in which user provided variables to render_to_response, RequestContext and context processors are loaded.
This commit is contained in:
parent
7271f5db78
commit
e7ffba8f78
|
@ -450,11 +450,11 @@ below.
|
||||||
|
|
||||||
.. admonition:: When context processors are applied
|
.. admonition:: When context processors are applied
|
||||||
|
|
||||||
When you use ``RequestContext``, the variables you supply directly
|
Context processors are applied *after* the context itself is processed.
|
||||||
are added first, followed any variables supplied by context
|
This means that a context processor may overwrite variables you've
|
||||||
processors. This means that a context processor may overwrite a
|
supplied to your ``Context`` or ``RequestContext``, so take care
|
||||||
variable you've supplied, so take care to avoid variable names
|
to avoid variable names that overlap with those supplied by your
|
||||||
which overlap with those supplied by your context processors.
|
context processors.
|
||||||
|
|
||||||
Also, you can give ``RequestContext`` a list of additional processors, using the
|
Also, you can give ``RequestContext`` a list of additional processors, using the
|
||||||
optional, third positional argument, ``processors``. In this example, the
|
optional, third positional argument, ``processors``. In this example, the
|
||||||
|
@ -496,6 +496,10 @@ optional, third positional argument, ``processors``. In this example, the
|
||||||
the same as a call to :func:`~django.shortcuts.render_to_response()` with a
|
the same as a call to :func:`~django.shortcuts.render_to_response()` with a
|
||||||
context_instance argument that forces the use of a ``RequestContext``.
|
context_instance argument that forces the use of a ``RequestContext``.
|
||||||
|
|
||||||
|
Note that the contents of a supplied dictionary (``my_data_dictionary``
|
||||||
|
in this example) will take precedence over any variables supplied by
|
||||||
|
context processors or the ``RequestContext``.
|
||||||
|
|
||||||
Here's what each of the default processors does:
|
Here's what each of the default processors does:
|
||||||
|
|
||||||
django.contrib.auth.context_processors.auth
|
django.contrib.auth.context_processors.auth
|
||||||
|
|
Loading…
Reference in New Issue