diff --git a/django/conf/project_template/project_name/settings.py b/django/conf/project_template/project_name/settings.py index a782ac4815..a0a3056075 100644 --- a/django/conf/project_template/project_name/settings.py +++ b/django/conf/project_template/project_name/settings.py @@ -61,10 +61,7 @@ TEMPLATES = [ 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', - 'django.template.context_processors.i18n', - 'django.template.context_processors.tz', - 'django.template.context_processors.media', - 'django.template.context_processors.static', + 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], diff --git a/docs/intro/tutorial02.txt b/docs/intro/tutorial02.txt index a49d6b531c..e45753b40f 100644 --- a/docs/intro/tutorial02.txt +++ b/docs/intro/tutorial02.txt @@ -501,10 +501,7 @@ Open your settings file (:file:`mysite/settings.py`, remember) and add a 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', - 'django.template.context_processors.i18n', - 'django.template.context_processors.tz', - 'django.template.context_processors.media', - 'django.template.context_processors.static', + 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt index 7dcdab9e79..db2850da6d 100644 --- a/docs/ref/settings.txt +++ b/docs/ref/settings.txt @@ -1873,10 +1873,9 @@ for :doc:`managing stored files `. It must end in a slash if set to a non-empty value. You will need to :ref:`configure these files to be served ` in both development and production. -In order to use ``{{ MEDIA_URL }}`` in your templates, you must have +If you want to use ``{{ MEDIA_URL }}`` in your templates, add ``'django.template.context_processors.media'`` in the ``'context_processors'`` -option of :setting:`TEMPLATES`. It's there by default, but be sure to include -it if you override that setting and want this behavior. +option of :setting:`TEMPLATES`. Example: ``"http://media.example.com/"`` diff --git a/docs/ref/templates/api.txt b/docs/ref/templates/api.txt index 7afbb44179..9faca5b9e1 100644 --- a/docs/ref/templates/api.txt +++ b/docs/ref/templates/api.txt @@ -554,12 +554,9 @@ settings file, the default template engine contains the following context processors:: [ - 'django.contrib.auth.context_processors.auth', 'django.template.context_processors.debug', - 'django.template.context_processors.i18n', - 'django.template.context_processors.media', - 'django.template.context_processors.static', - 'django.template.context_processors.tz', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ] @@ -625,7 +622,7 @@ Built-in template context processors Context processors ------------------ -Here's what each of the default processors does: +Here's what each of the built-in processors does: django.contrib.auth.context_processors.auth ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -695,8 +692,7 @@ django.template.context_processors.request ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If this processor is enabled, every ``RequestContext`` will contain a variable -``request``, which is the current :class:`~django.http.HttpRequest`. Note that -this processor is not enabled by default; you'll have to activate it. +``request``, which is the current :class:`~django.http.HttpRequest`. django.contrib.messages.context_processors.messages ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/topics/i18n/timezones.txt b/docs/topics/i18n/timezones.txt index 0360b4789b..d6e07d0229 100644 --- a/docs/topics/i18n/timezones.txt +++ b/docs/topics/i18n/timezones.txt @@ -208,6 +208,7 @@ Include a form in ``template.html`` that will ``POST`` to this view: .. code-block:: html+django {% load tz %} + {% get_current_timezone as TIME_ZONE %}
{% csrf_token %} @@ -311,16 +312,15 @@ time zone is unset, the default time zone applies. get_current_timezone ~~~~~~~~~~~~~~~~~~~~ -When the ``django.template.context_processors.tz`` context processor is -enabled -- by default, it is -- each :class:`~django.template.RequestContext` -contains a ``TIME_ZONE`` variable that provides the name of the current time -zone. - -If you don't use a :class:`~django.template.RequestContext`, you can obtain -this value with the ``get_current_timezone`` tag:: +You can get the name of the current time zone using the +``get_current_timezone`` tag:: {% get_current_timezone as TIME_ZONE %} +If you enable the ``django.template.context_processors.tz`` context processor, +each :class:`~django.template.RequestContext` will contain a ``TIME_ZONE`` +variable with the value of ``get_current_timezone()``. + Template filters ---------------- diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt index a01cb84b69..ad618c9d5a 100644 --- a/docs/topics/i18n/translation.txt +++ b/docs/topics/i18n/translation.txt @@ -28,8 +28,6 @@ bit of i18n-related overhead in certain places of the framework. If you don't use internationalization, you should take the two seconds to set :setting:`USE_I18N = False ` in your settings file. Then Django will make some optimizations so as not to load the internationalization machinery. -You'll probably also want to remove ``'django.template.context_processors.i18n'`` -from the ``'context_processors'`` option of your :setting:`TEMPLATES` setting. .. note:: @@ -812,28 +810,29 @@ the second will always be in English. Other tags ---------- -Each ``RequestContext`` has access to three translation-specific variables: - -* ``LANGUAGES`` is a list of tuples in which the first element is the - :term:`language code` and the second is the language name (translated into - the currently active locale). - -* ``LANGUAGE_CODE`` is the current user's preferred language, as a string. - Example: ``en-us``. (See :ref:`how-django-discovers-language-preference`.) - -* ``LANGUAGE_BIDI`` is the current locale's direction. If True, it's a - right-to-left language, e.g.: Hebrew, Arabic. If False it's a - left-to-right language, e.g.: English, French, German etc. - -If you don't use the ``RequestContext`` extension, you can get those values with -three tags:: - - {% get_current_language as LANGUAGE_CODE %} - {% get_available_languages as LANGUAGES %} - {% get_current_language_bidi as LANGUAGE_BIDI %} - These tags also require a ``{% load i18n %}``. +* ``{% get_available_languages as LANGUAGES %}`` returns a list of tuples in + which the first element is the :term:`language code` and the second is the + language name (translated into the currently active locale). + +* ``{% get_current_language as LANGUAGE_CODE %}`` returns the current user's + preferred language, as a string. Example: ``en-us``. (See + :ref:`how-django-discovers-language-preference`.) + +* ``{% get_current_language_bidi as LANGUAGE_BIDI %}`` returns the current + locale's direction. If True, it's a right-to-left language, e.g.: Hebrew, + Arabic. If False it's a left-to-right language, e.g.: English, French, German + etc. + +If you enable the ``django.template.context_processors.i18n`` context processor +then each ``RequestContext`` will have access to ``LANGUAGES``, +``LANGUAGE_CODE``, and ``LANGUAGE_BIDI`` as defined above. + +.. versionchanged:: 1.8 + + The ``i18n`` context processor is not enabled by default for new projects. + You can also retrieve information about any of the available languages using provided template tags and filters. To get information about a single language, use the ``{% get_language_info %}`` tag:: @@ -1506,11 +1505,6 @@ 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, back to the previous page. -Make sure that the following context processor is enabled in the -:setting:`TEMPLATES` setting in your settings file:: - - 'django.template.context_processors.i18n' - Activate this view by adding the following line to your URLconf:: url(r'^i18n/', include('django.conf.urls.i18n')), @@ -1542,10 +1536,13 @@ Here's example HTML template code: .. code-block:: html+django + {% load i18n %} {% csrf_token %}