Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
9eb4f28e
Kaydet (Commit)
9eb4f28e
authored
Ara 17, 2014
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Deprecated TEMPLATE_CONTEXT_PROCESSORS.
üst
d3205e3e
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
144 additions
and
90 deletions
+144
-90
sites.py
django/contrib/admin/sites.py
+2
-2
context.py
django/template/context.py
+1
-1
context_processors.py
django/template/context_processors.py
+3
-2
deprecation.txt
docs/internals/deprecation.txt
+1
-0
mixins-simple.txt
docs/ref/class-based-views/mixins-simple.txt
+4
-5
index.txt
docs/ref/contrib/admin/index.txt
+2
-1
messages.txt
docs/ref/contrib/messages.txt
+3
-2
csrf.txt
docs/ref/csrf.txt
+4
-4
settings.txt
docs/ref/settings.txt
+16
-5
api.txt
docs/ref/templates/api.txt
+46
-39
views.txt
docs/ref/views.txt
+2
-2
1.8.txt
docs/releases/1.8.txt
+1
-0
default.txt
docs/topics/auth/default.txt
+5
-5
translation.txt
docs/topics/i18n/translation.txt
+3
-3
tests.py
tests/admin_views/tests.py
+19
-9
tests.py
tests/context_processors/tests.py
+18
-2
tests.py
tests/shortcuts/tests.py
+0
-1
tests.py
tests/template_tests/tests.py
+5
-4
tests.py
tests/test_client_regress/tests.py
+9
-3
No files found.
django/contrib/admin/sites.py
Dosyayı görüntüle @
9eb4f28e
...
@@ -174,8 +174,8 @@ class AdminSite(object):
...
@@ -174,8 +174,8 @@ class AdminSite(object):
raise
ImproperlyConfigured
(
"Put 'django.contrib.contenttypes' in "
raise
ImproperlyConfigured
(
"Put 'django.contrib.contenttypes' in "
"your INSTALLED_APPS setting in order to use the admin application."
)
"your INSTALLED_APPS setting in order to use the admin application."
)
if
'django.contrib.auth.context_processors.auth'
not
in
Engine
.
get_default
()
.
context_processors
:
if
'django.contrib.auth.context_processors.auth'
not
in
Engine
.
get_default
()
.
context_processors
:
raise
ImproperlyConfigured
(
"
Put
'django.contrib.auth.context_processors.auth' "
raise
ImproperlyConfigured
(
"
Enable
'django.contrib.auth.context_processors.auth' "
"in your TEMPLATE
_CONTEXT_PROCESSOR
S setting in order to use the admin application."
)
"in your TEMPLATES setting in order to use the admin application."
)
def
admin_view
(
self
,
view
,
cacheable
=
False
):
def
admin_view
(
self
,
view
,
cacheable
=
False
):
"""
"""
...
...
django/template/context.py
Dosyayı görüntüle @
9eb4f28e
...
@@ -187,7 +187,7 @@ class RenderContext(BaseContext):
...
@@ -187,7 +187,7 @@ class RenderContext(BaseContext):
class
RequestContext
(
Context
):
class
RequestContext
(
Context
):
"""
"""
This subclass of template.Context automatically populates itself using
This subclass of template.Context automatically populates itself using
the processors defined in
TEMPLATE_CONTEXT_PROCESSORS
.
the processors defined in
the engine's configuration
.
Additional processors can be specified as a list of callables
Additional processors can be specified as a list of callables
using the "processors" keyword argument.
using the "processors" keyword argument.
"""
"""
...
...
django/template/context_processors.py
Dosyayı görüntüle @
9eb4f28e
...
@@ -3,9 +3,10 @@ A set of request processors that return dictionaries to be merged into a
...
@@ -3,9 +3,10 @@ A set of request processors that return dictionaries to be merged into a
template context. Each function takes the request object as its only parameter
template context. Each function takes the request object as its only parameter
and returns a dictionary to add to the context.
and returns a dictionary to add to the context.
These are referenced from the
setting TEMPLATE_CONTEXT_PROCESSORS and used by
These are referenced from the
'context_processors' option of the configuration
RequestContext.
of a DjangoTemplates backend and used by
RequestContext.
"""
"""
from
__future__
import
unicode_literals
from
__future__
import
unicode_literals
from
django.conf
import
settings
from
django.conf
import
settings
...
...
docs/internals/deprecation.txt
Dosyayı görüntüle @
9eb4f28e
...
@@ -90,6 +90,7 @@ details on these changes.
...
@@ -90,6 +90,7 @@ details on these changes.
* The following settings will be removed:
* The following settings will be removed:
* ``ALLOWED_INCLUDE_ROOTS``
* ``ALLOWED_INCLUDE_ROOTS``
* ``TEMPLATE_CONTEXT_PROCESSORS``
* ``TEMPLATE_DIRS``
* ``TEMPLATE_DIRS``
* ``TEMPLATE_LOADERS``
* ``TEMPLATE_LOADERS``
* ``TEMPLATE_STRING_IF_INVALID``
* ``TEMPLATE_STRING_IF_INVALID``
...
...
docs/ref/class-based-views/mixins-simple.txt
Dosyayı görüntüle @
9eb4f28e
...
@@ -61,11 +61,10 @@ TemplateResponseMixin
...
@@ -61,11 +61,10 @@ TemplateResponseMixin
.. versionchanged:: 1.8
.. versionchanged:: 1.8
In older versions of Django, ``TemplateResponse`` used
In older versions of Django, ``TemplateResponse`` used
:class:`~django.template.RequestContext` in such a way that
:class:`~django.template.RequestContext` in such a way that values
callables defined in :setting:`TEMPLATE_CONTEXT_PROCESSORS` would
from template context processors would override template variables
override template variables defined in your views. For example, if
defined in your views. For example, if you subclassed
you subclassed :class:`DetailView
:class:`DetailView <django.views.generic.detail.DetailView>` and
<django.views.generic.detail.DetailView>` and
set ``context_object_name`` to ``user``, the
set ``context_object_name`` to ``user``, the
``django.contrib.auth.context_processors.auth`` context processor
``django.contrib.auth.context_processors.auth`` context processor
would overwrite your variable with the current user. Now, for
would overwrite your variable with the current user. Now, for
...
...
docs/ref/contrib/admin/index.txt
Dosyayı görüntüle @
9eb4f28e
...
@@ -28,7 +28,8 @@ For reference, here are the requirements:
...
@@ -28,7 +28,8 @@ For reference, here are the requirements:
in your :setting:`INSTALLED_APPS` list, add them.
in your :setting:`INSTALLED_APPS` list, add them.
3. Add ``django.contrib.messages.context_processors.messages`` to
3. Add ``django.contrib.messages.context_processors.messages`` to
:setting:`TEMPLATE_CONTEXT_PROCESSORS` as well as
the ``'context_processors'`` option of the ``DjangoTemplates`` backend
defined in your :setting:`TEMPLATES` as well as
:class:`django.contrib.auth.middleware.AuthenticationMiddleware` and
:class:`django.contrib.auth.middleware.AuthenticationMiddleware` and
:class:`django.contrib.messages.middleware.MessageMiddleware` to
:class:`django.contrib.messages.middleware.MessageMiddleware` to
:setting:`MIDDLEWARE_CLASSES`. (These are all active by default, so
:setting:`MIDDLEWARE_CLASSES`. (These are all active by default, so
...
...
docs/ref/contrib/messages.txt
Dosyayı görüntüle @
9eb4f28e
...
@@ -36,13 +36,14 @@ already contains all the settings required to enable message functionality:
...
@@ -36,13 +36,14 @@ already contains all the settings required to enable message functionality:
must be enabled and appear before ``MessageMiddleware`` in
must be enabled and appear before ``MessageMiddleware`` in
:setting:`MIDDLEWARE_CLASSES`.
:setting:`MIDDLEWARE_CLASSES`.
* :setting:`TEMPLATE_CONTEXT_PROCESSORS` contains
* The ``'context_processors'`` option of the ``DjangoTemplates`` backend
defined in your :setting:`TEMPLATES` setting contains
``'django.contrib.messages.context_processors.messages'``.
``'django.contrib.messages.context_processors.messages'``.
If you don't want to use messages, you can remove
If you don't want to use messages, you can remove
``'django.contrib.messages'`` from your :setting:`INSTALLED_APPS`, the
``'django.contrib.messages'`` from your :setting:`INSTALLED_APPS`, the
``MessageMiddleware`` line from :setting:`MIDDLEWARE_CLASSES`, and the
``MessageMiddleware`` line from :setting:`MIDDLEWARE_CLASSES`, and the
``messages`` context processor from :setting:`TEMPLATE
_CONTEXT_PROCESSOR
S`.
``messages`` context processor from :setting:`TEMPLATES`.
Configuring the message engine
Configuring the message engine
==============================
==============================
...
...
docs/ref/csrf.txt
Dosyayı görüntüle @
9eb4f28e
...
@@ -50,10 +50,10 @@ To take advantage of CSRF protection in your views, follow these steps:
...
@@ -50,10 +50,10 @@ To take advantage of CSRF protection in your views, follow these steps:
being used. Usually, this can be done in one of two ways:
being used. Usually, this can be done in one of two ways:
1. Use RequestContext, which always uses
1. Use RequestContext, which always uses
``'django.template.context_processors.csrf'`` (no matter what
your
``'django.template.context_processors.csrf'`` (no matter what
template
TEMPLATE_CONTEXT_PROCESSORS setting). If you are using
context processors are configured in the :setting:`TEMPLATES` setting).
generic views or contrib apps, you are covered already, since these
If you are using generic views or contrib apps, you are covered already,
apps use RequestContext throughout.
since these
apps use RequestContext throughout.
2. Manually import and use the processor to generate the CSRF token and
2. Manually import and use the processor to generate the CSRF token and
add it to the template context. e.g.::
add it to the template context. e.g.::
...
...
docs/ref/settings.txt
Dosyayı görüntüle @
9eb4f28e
...
@@ -10,8 +10,8 @@ Settings
...
@@ -10,8 +10,8 @@ Settings
Be careful when you override settings, especially when the default value
Be careful when you override settings, especially when the default value
is a non-empty tuple or dictionary, such as :setting:`MIDDLEWARE_CLASSES`
is a non-empty tuple or dictionary, such as :setting:`MIDDLEWARE_CLASSES`
and :setting:`
TEMPLATE_CONTEXT_PROCESSORS`. Make sure you keep the
and :setting:`
STATICFILES_FINDERS`. Make sure you keep the components
components
required by the features of Django you wish to use.
required by the features of Django you wish to use.
Core settings
Core settings
=============
=============
...
@@ -1868,9 +1868,9 @@ to a non-empty value. You will need to :ref:`configure these files to be served
...
@@ -1868,9 +1868,9 @@ to a non-empty value. You will need to :ref:`configure these files to be served
<serving-uploaded-files-in-development>` in both development and production.
<serving-uploaded-files-in-development>` in both development and production.
In order to use ``{{ MEDIA_URL }}`` in your templates, you must have
In order to use ``{{ MEDIA_URL }}`` in your templates, you must have
``'django.template.context_processors.media'`` in
your
``'django.template.context_processors.media'`` in
the ``'context_processors'``
:setting:`TEMPLATE_CONTEXT_PROCESSORS`. It's there by default, but be sur
e
option of :setting:`TEMPLATES`. It's there by default, but be sure to includ
e
to include
it if you override that setting and want this behavior.
it if you override that setting and want this behavior.
Example: ``"http://media.example.com/"``
Example: ``"http://media.example.com/"``
...
@@ -2394,10 +2394,21 @@ Default::
...
@@ -2394,10 +2394,21 @@ Default::
"django.template.context_processors.tz",
"django.template.context_processors.tz",
"django.contrib.messages.context_processors.messages")
"django.contrib.messages.context_processors.messages")
.. deprecated:: 1.8
Set the ``'context_processors'`` option in the :setting:`OPTIONS
<TEMPLATES-OPTIONS>` of a ``DjangoTemplates`` backend instead.
A tuple of callables that are used to populate the context in ``RequestContext``.
A tuple of callables that are used to populate the context in ``RequestContext``.
These callables take a request object as their argument and return a dictionary
These callables take a request object as their argument and return a dictionary
of items to be merged into the context.
of items to be merged into the context.
.. versionchanged:: 1.8
Built-in template context processors were moved from
``django.core.context_processors`` to
``django.template.context_processors`` in Django 1.8.
.. setting:: TEMPLATE_DEBUG
.. setting:: TEMPLATE_DEBUG
TEMPLATE_DEBUG
TEMPLATE_DEBUG
...
...
docs/ref/templates/api.txt
Dosyayı görüntüle @
9eb4f28e
...
@@ -446,27 +446,37 @@ normal ``django.template.Context``. The first difference is that it takes an
...
@@ -446,27 +446,37 @@ normal ``django.template.Context``. The first difference is that it takes an
'foo': 'bar',
'foo': 'bar',
})
})
The second difference is that it automatically populates the context with a few
The second difference is that it automatically populates the context with a
variables, according to your :setting:`TEMPLATE_CONTEXT_PROCESSORS` setting.
few variables, according to the ``'context_processors'`` option in the
:setting:`TEMPLATES` setting.
The :setting:`TEMPLATE_CONTEXT_PROCESSORS` setting is a tuple of callables --
called **context processors** -- that take a request object as their argument
The ``'context_processors'`` option is a list of callables -- called **context
and return a dictionary of items to be merged into the context. By default,
processors** -- that take a request object as their argument and return a
:setting:`TEMPLATE_CONTEXT_PROCESSORS` is set to::
dictionary of items to be merged into the context. In the default generated
settings file, the default template engine contains the following context
("django.contrib.auth.context_processors.auth",
processors::
"django.template.context_processors.debug",
"django.template.context_processors.i18n",
[
"django.template.context_processors.media",
'django.contrib.auth.context_processors.auth',
"django.template.context_processors.static",
'django.template.context_processors.debug',
"django.template.context_processors.tz",
'django.template.context_processors.i18n',
"django.contrib.messages.context_processors.messages")
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
]
.. versionchanged:: 1.8
Built-in template context processors were moved from
``django.core.context_processors`` to
``django.template.context_processors`` in Django 1.8.
In addition to these, ``RequestContext`` always uses
In addition to these, ``RequestContext`` always uses
``django.template.context_processors.csrf``. This is a security
``django.template.context_processors.csrf``. This is a security
related context processor required by the admin and other contrib apps, and,
related context processor required by the admin and other contrib apps, and,
in case of accidental misconfiguration, it is deliberately hardcoded in and
in case of accidental misconfiguration, it is deliberately hardcoded in and
cannot be turned off
by the :setting:`TEMPLATE_CONTEXT_PROCESSORS` setting
.
cannot be turned off
in the ``'context_processors'`` option
.
Each processor is applied in order. That means, if one processor adds a
Each processor is applied in order. That means, if one processor adds a
variable to the context and a second processor adds a variable with the same
variable to the context and a second processor adds a variable with the same
...
@@ -513,8 +523,8 @@ Here's what each of the default processors does:
...
@@ -513,8 +523,8 @@ Here's what each of the default processors does:
django.contrib.auth.context_processors.auth
django.contrib.auth.context_processors.auth
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If
:setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every
If
this processor is enabled, every ``RequestContext`` will contain these
``RequestContext`` will contain these
variables:
variables:
* ``user`` -- An ``auth.User`` instance representing the currently
* ``user`` -- An ``auth.User`` instance representing the currently
logged-in user (or an ``AnonymousUser`` instance, if the client isn't
logged-in user (or an ``AnonymousUser`` instance, if the client isn't
...
@@ -529,10 +539,10 @@ If :setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every
...
@@ -529,10 +539,10 @@ If :setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every
django.template.context_processors.debug
django.template.context_processors.debug
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If
:setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every
If
this processor is enabled, every ``RequestContext`` will contain these two
``RequestContext`` will contain these two variables -- but only if your
variables -- but only if your :setting:`DEBUG` setting is set to ``True`` and
:setting:`DEBUG` setting is set to ``True`` and the request's IP address
the request's IP address (``request.META['REMOTE_ADDR']``) is in the
(``request.META['REMOTE_ADDR']``) is in the
:setting:`INTERNAL_IPS` setting:
:setting:`INTERNAL_IPS` setting:
* ``debug`` -- ``True``. You can use this in templates to test whether
* ``debug`` -- ``True``. You can use this in templates to test whether
you're in :setting:`DEBUG` mode.
you're in :setting:`DEBUG` mode.
...
@@ -544,8 +554,8 @@ If :setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every
...
@@ -544,8 +554,8 @@ If :setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every
django.template.context_processors.i18n
django.template.context_processors.i18n
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If
:setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every
If
this processor is enabled, every ``RequestContext`` will contain these two
``RequestContext`` will contain these two
variables:
variables:
* ``LANGUAGES`` -- The value of the :setting:`LANGUAGES` setting.
* ``LANGUAGES`` -- The value of the :setting:`LANGUAGES` setting.
* ``LANGUAGE_CODE`` -- ``request.LANGUAGE_CODE``, if it exists. Otherwise,
* ``LANGUAGE_CODE`` -- ``request.LANGUAGE_CODE``, if it exists. Otherwise,
...
@@ -556,18 +566,16 @@ See :doc:`/topics/i18n/index` for more.
...
@@ -556,18 +566,16 @@ See :doc:`/topics/i18n/index` for more.
django.template.context_processors.media
django.template.context_processors.media
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If :setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every
If this processor is enabled, every ``RequestContext`` will contain a variable
``RequestContext`` will contain a variable ``MEDIA_URL``, providing the
``MEDIA_URL``, providing the value of the :setting:`MEDIA_URL` setting.
value of the :setting:`MEDIA_URL` setting.
django.template.context_processors.static
django.template.context_processors.static
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. function:: static
.. function:: static
If :setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every
If this processor is enabled, every ``RequestContext`` will contain a variable
``RequestContext`` will contain a variable ``STATIC_URL``, providing the
``STATIC_URL``, providing the value of the :setting:`STATIC_URL` setting.
value of the :setting:`STATIC_URL` setting.
django.template.context_processors.csrf
django.template.context_processors.csrf
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
@@ -579,16 +587,15 @@ tag for protection against :doc:`Cross Site Request Forgeries
...
@@ -579,16 +587,15 @@ tag for protection against :doc:`Cross Site Request Forgeries
django.template.context_processors.request
django.template.context_processors.request
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If :setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every
If this processor is enabled, every ``RequestContext`` will contain a variable
``RequestContext`` will contain a variable ``request``, which is the current
``request``, which is the current :class:`~django.http.HttpRequest`. Note that
:class:`~django.http.HttpRequest`. Note that this processor is not enabled by default;
this processor is not enabled by default; you'll have to activate it.
you'll have to activate it.
django.contrib.messages.context_processors.messages
django.contrib.messages.context_processors.messages
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If
:setting:`TEMPLATE_CONTEXT_PROCESSORS` contains this processor, every
If
this processor is enabled, every ``RequestContext`` will contain these two
``RequestContext`` will contain these two
variables:
variables:
* ``messages`` -- A list of messages (as strings) that have been set
* ``messages`` -- A list of messages (as strings) that have been set
via the :doc:`messages framework </ref/contrib/messages>`.
via the :doc:`messages framework </ref/contrib/messages>`.
...
@@ -607,9 +614,9 @@ that takes one argument, an :class:`~django.http.HttpRequest` object, and
...
@@ -607,9 +614,9 @@ that takes one argument, an :class:`~django.http.HttpRequest` object, and
returns a dictionary that gets added to the template context. Each context
returns a dictionary that gets added to the template context. Each context
processor *must* return a dictionary.
processor *must* return a dictionary.
Custom context processors can live anywhere in your code base. All Django
cares
Custom context processors can live anywhere in your code base. All Django
about is that your custom context processors are pointed-to by your
cares about is that your custom context processors are pointed to by the
:setting:`TEMPLATE_CONTEXT_PROCESSOR
S` setting.
``'context_processors'`` option in your :setting:`TEMPLATE
S` setting.
Loading templates
Loading templates
-----------------
-----------------
...
...
docs/ref/views.txt
Dosyayı görüntüle @
9eb4f28e
...
@@ -78,8 +78,8 @@ Three things to note about 404 views:
...
@@ -78,8 +78,8 @@ Three things to note about 404 views:
checking every regular expression in the URLconf.
checking every regular expression in the URLconf.
* The 404 view is passed a :class:`~django.template.RequestContext` and
* The 404 view is passed a :class:`~django.template.RequestContext` and
will have access to variables supplied by your
will have access to variables supplied by your
template context
:setting:`TEMPLATE_CONTEXT_PROCESSORS` setting (e.g.,
``MEDIA_URL``).
processors (e.g.
``MEDIA_URL``).
* If :setting:`DEBUG` is set to ``True`` (in your settings module), then
* If :setting:`DEBUG` is set to ``True`` (in your settings module), then
your 404 view will never be used, and your URLconf will be displayed
your 404 view will never be used, and your URLconf will be displayed
...
...
docs/releases/1.8.txt
Dosyayı görüntüle @
9eb4f28e
...
@@ -1021,6 +1021,7 @@ As a consequence of the multiple template engines refactor, several settings
...
@@ -1021,6 +1021,7 @@ As a consequence of the multiple template engines refactor, several settings
are deprecated in favor of :setting:`TEMPLATES`:
are deprecated in favor of :setting:`TEMPLATES`:
* ``ALLOWED_INCLUDE_ROOTS``
* ``ALLOWED_INCLUDE_ROOTS``
* ``TEMPLATE_CONTEXT_PROCESSORS``
* ``TEMPLATE_DIRS``
* ``TEMPLATE_DIRS``
* ``TEMPLATE_LOADERS``
* ``TEMPLATE_LOADERS``
* ``TEMPLATE_STRING_IF_INVALID``
* ``TEMPLATE_STRING_IF_INVALID``
...
...
docs/topics/auth/default.txt
Dosyayı görüntüle @
9eb4f28e
...
@@ -1264,11 +1264,11 @@ The currently logged-in user and their permissions are made available in the
...
@@ -1264,11 +1264,11 @@ The currently logged-in user and their permissions are made available in the
.. admonition:: Technicality
.. admonition:: Technicality
Technically, these variables are only made available in the template
context
Technically, these variables are only made available in the template
if you use :class:`~django.template.RequestContext` *and* your
context if you use :class:`~django.template.RequestContext` and the
:setting:`TEMPLATE_CONTEXT_PROCESSORS` setting contain
s
``'django.contrib.auth.context_processors.auth'`` context processor i
s
``"django.contrib.auth.context_processors.auth"``, which is default. For
enabled. It is in the default generated settings file. For more, see the
more, see the
:ref:`RequestContext docs <subclassing-context-requestcontext>`.
:ref:`RequestContext docs <subclassing-context-requestcontext>`.
Users
Users
~~~~~
~~~~~
...
...
docs/topics/i18n/translation.txt
Dosyayı görüntüle @
9eb4f28e
...
@@ -29,7 +29,7 @@ use internationalization, you should take the two seconds to set
...
@@ -29,7 +29,7 @@ use internationalization, you should take the two seconds to set
:setting:`USE_I18N = False <USE_I18N>` in your settings file. Then Django will
:setting:`USE_I18N = False <USE_I18N>` in your settings file. Then Django will
make some optimizations so as not to load the internationalization machinery.
make some optimizations so as not to load the internationalization machinery.
You'll probably also want to remove ``'django.template.context_processors.i18n'``
You'll probably also want to remove ``'django.template.context_processors.i18n'``
from
your :setting:`TEMPLATE_CONTEXT_PROCESSOR
S` setting.
from
the ``'context_processors'`` option of your :setting:`TEMPLATE
S` setting.
.. note::
.. note::
...
@@ -1506,8 +1506,8 @@ As a convenience, Django comes with a view, :func:`django.views.i18n.set_languag
...
@@ -1506,8 +1506,8 @@ As a convenience, Django comes with a view, :func:`django.views.i18n.set_languag
that sets a user's language preference and redirects to a given URL or, by default,
that sets a user's language preference and redirects to a given URL or, by default,
back to the previous page.
back to the previous page.
Make sure that the following
item is in your
Make sure that the following
context processor is enabled in the
:setting:`TEMPLATE
_CONTEXT_PROCESSORS` list
in your settings file::
:setting:`TEMPLATE
S` setting
in your settings file::
'django.template.context_processors.i18n'
'django.template.context_processors.i18n'
...
...
tests/admin_views/tests.py
Dosyayı görüntüle @
9eb4f28e
...
@@ -6,7 +6,6 @@ import re
...
@@ -6,7 +6,6 @@ import re
import
datetime
import
datetime
import
unittest
import
unittest
from
django.conf
import
global_settings
from
django.core
import
mail
from
django.core
import
mail
from
django.core.checks
import
Error
from
django.core.checks
import
Error
from
django.core.files
import
temp
as
tempfile
from
django.core.files
import
temp
as
tempfile
...
@@ -4349,8 +4348,25 @@ class AdminDocsTest(TestCase):
...
@@ -4349,8 +4348,25 @@ class AdminDocsTest(TestCase):
self
.
assertContains
(
response
,
'<li><a href="#built_in-add">add</a></li>'
,
html
=
True
)
self
.
assertContains
(
response
,
'<li><a href="#built_in-add">add</a></li>'
,
html
=
True
)
@override_settings
(
PASSWORD_HASHERS
=
(
'django.contrib.auth.hashers.SHA1PasswordHasher'
,),
@override_settings
(
ROOT_URLCONF
=
"admin_views.urls"
)
PASSWORD_HASHERS
=
(
'django.contrib.auth.hashers.SHA1PasswordHasher'
,),
ROOT_URLCONF
=
"admin_views.urls"
,
TEMPLATES
=
[{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'context_processors'
:
[
'django.template.context_processors.debug'
,
'django.template.context_processors.tz'
,
'django.template.context_processors.media'
,
'django.template.context_processors.static'
,
'django.contrib.auth.context_processors.auth'
,
'django.contrib.messages.context_processors.messages'
,
],
},
}],
USE_I18N
=
False
,
)
class
ValidXHTMLTests
(
TestCase
):
class
ValidXHTMLTests
(
TestCase
):
fixtures
=
[
'admin-views-users.xml'
]
fixtures
=
[
'admin-views-users.xml'
]
urlbit
=
'admin'
urlbit
=
'admin'
...
@@ -4358,12 +4374,6 @@ class ValidXHTMLTests(TestCase):
...
@@ -4358,12 +4374,6 @@ class ValidXHTMLTests(TestCase):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
client
.
login
(
username
=
'super'
,
password
=
'secret'
)
self
.
client
.
login
(
username
=
'super'
,
password
=
'secret'
)
@override_settings
(
TEMPLATE_CONTEXT_PROCESSORS
=
filter
(
lambda
t
:
t
!=
'django.template.context_processors.i18n'
,
global_settings
.
TEMPLATE_CONTEXT_PROCESSORS
),
USE_I18N
=
False
,
)
def
test_lang_name_present
(
self
):
def
test_lang_name_present
(
self
):
response
=
self
.
client
.
get
(
'/test_admin/
%
s/admin_views/'
%
self
.
urlbit
)
response
=
self
.
client
.
get
(
'/test_admin/
%
s/admin_views/'
%
self
.
urlbit
)
self
.
assertNotContains
(
response
,
' lang=""'
)
self
.
assertNotContains
(
response
,
' lang=""'
)
...
...
tests/context_processors/tests.py
Dosyayı görüntüle @
9eb4f28e
...
@@ -6,7 +6,15 @@ from django.test import TestCase, override_settings
...
@@ -6,7 +6,15 @@ from django.test import TestCase, override_settings
@override_settings
(
@override_settings
(
ROOT_URLCONF
=
'context_processors.urls'
,
ROOT_URLCONF
=
'context_processors.urls'
,
TEMPLATE_CONTEXT_PROCESSORS
=
(
'django.template.context_processors.request'
,),
TEMPLATES
=
[{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'context_processors'
:
[
'django.template.context_processors.request'
,
],
},
}],
)
)
class
RequestContextProcessorTests
(
TestCase
):
class
RequestContextProcessorTests
(
TestCase
):
"""
"""
...
@@ -42,7 +50,15 @@ class RequestContextProcessorTests(TestCase):
...
@@ -42,7 +50,15 @@ class RequestContextProcessorTests(TestCase):
DEBUG
=
True
,
DEBUG
=
True
,
INTERNAL_IPS
=
(
'127.0.0.1'
,),
INTERNAL_IPS
=
(
'127.0.0.1'
,),
ROOT_URLCONF
=
'context_processors.urls'
,
ROOT_URLCONF
=
'context_processors.urls'
,
TEMPLATE_CONTEXT_PROCESSORS
=
(
'django.template.context_processors.debug'
,),
TEMPLATES
=
[{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'context_processors'
:
[
'django.template.context_processors.debug'
,
],
},
}],
)
)
class
DebugContextProcessorTests
(
TestCase
):
class
DebugContextProcessorTests
(
TestCase
):
"""
"""
...
...
tests/shortcuts/tests.py
Dosyayı görüntüle @
9eb4f28e
...
@@ -4,7 +4,6 @@ from django.test import TestCase, override_settings
...
@@ -4,7 +4,6 @@ from django.test import TestCase, override_settings
@override_settings
(
@override_settings
(
TEMPLATE_CONTEXT_PROCESSORS
=
(
'django.template.context_processors.static'
,),
STATIC_URL
=
'/path/to/static/media/'
,
STATIC_URL
=
'/path/to/static/media/'
,
ROOT_URLCONF
=
'shortcuts.urls'
,
ROOT_URLCONF
=
'shortcuts.urls'
,
)
)
...
...
tests/template_tests/tests.py
Dosyayı görüntüle @
9eb4f28e
...
@@ -486,8 +486,10 @@ class RequestContextTests(unittest.TestCase):
...
@@ -486,8 +486,10 @@ class RequestContextTests(unittest.TestCase):
# [builtins, supplied context, context processor]
# [builtins, supplied context, context processor]
self
.
assertEqual
(
len
(
ctx
.
dicts
),
3
)
self
.
assertEqual
(
len
(
ctx
.
dicts
),
3
)
@override_settings
(
TEMPLATE_CONTEXT_PROCESSORS
=
())
def
test_context_comparable
(
self
):
def
test_context_comparable
(
self
):
# Create an engine without any context processors.
engine
=
Engine
()
test_data
=
{
'x'
:
'y'
,
'v'
:
'z'
,
'd'
:
{
'o'
:
object
,
'a'
:
'b'
}}
test_data
=
{
'x'
:
'y'
,
'v'
:
'z'
,
'd'
:
{
'o'
:
object
,
'a'
:
'b'
}}
# test comparing RequestContext to prevent problems if somebody
# test comparing RequestContext to prevent problems if somebody
...
@@ -495,9 +497,8 @@ class RequestContextTests(unittest.TestCase):
...
@@ -495,9 +497,8 @@ class RequestContextTests(unittest.TestCase):
request
=
RequestFactory
()
.
get
(
'/'
)
request
=
RequestFactory
()
.
get
(
'/'
)
self
.
assertEqual
(
self
.
assertEqual
(
RequestContext
(
request
,
dict_
=
test_data
),
RequestContext
(
request
,
dict_
=
test_data
,
engine
=
engine
),
RequestContext
(
request
,
dict_
=
test_data
)
RequestContext
(
request
,
dict_
=
test_data
,
engine
=
engine
))
)
class
SSITests
(
SimpleTestCase
):
class
SSITests
(
SimpleTestCase
):
...
...
tests/test_client_regress/tests.py
Dosyayı görüntüle @
9eb4f28e
...
@@ -1004,9 +1004,15 @@ class ContextTests(TestCase):
...
@@ -1004,9 +1004,15 @@ class ContextTests(TestCase):
# Need to insert a context processor that assumes certain things about
# Need to insert a context processor that assumes certain things about
# the request instance. This triggers a bug caused by some ways of
# the request instance. This triggers a bug caused by some ways of
# copying RequestContext.
# copying RequestContext.
with
self
.
settings
(
TEMPLATE_CONTEXT_PROCESSORS
=
(
with
self
.
settings
(
TEMPLATES
=
[{
'test_client_regress.context_processors.special'
,
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
)):
'APP_DIRS'
:
True
,
'OPTIONS'
:
{
'context_processors'
:
[
'test_client_regress.context_processors.special'
,
],
},
}]):
response
=
self
.
client
.
get
(
"/request_context_view/"
)
response
=
self
.
client
.
get
(
"/request_context_view/"
)
self
.
assertContains
(
response
,
'Path: /request_context_view/'
)
self
.
assertContains
(
response
,
'Path: /request_context_view/'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment