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
26a92619
Kaydet (Commit)
26a92619
authored
Ock 12, 2015
tarafından
Collin Anderson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #24124 -- Changed context_processors in the default settings.py
üst
bbbed99f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
48 deletions
+34
-48
settings.py
django/conf/project_template/project_name/settings.py
+1
-4
tutorial02.txt
docs/intro/tutorial02.txt
+1
-4
settings.txt
docs/ref/settings.txt
+2
-3
api.txt
docs/ref/templates/api.txt
+4
-8
timezones.txt
docs/topics/i18n/timezones.txt
+7
-7
translation.txt
docs/topics/i18n/translation.txt
+19
-22
No files found.
django/conf/project_template/project_name/settings.py
Dosyayı görüntüle @
26a92619
...
...
@@ -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'
,
],
...
...
docs/intro/tutorial02.txt
Dosyayı görüntüle @
26a92619
...
...
@@ -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',
],
...
...
docs/ref/settings.txt
Dosyayı görüntüle @
26a92619
...
...
@@ -1873,10 +1873,9 @@ for :doc:`managing stored files </topics/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
<serving-uploaded-files-in-development>` in both development and production.
I
n order to use ``{{ MEDIA_URL }}`` in your templates, you must have
I
f 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/"``
...
...
docs/ref/templates/api.txt
Dosyayı görüntüle @
26a92619
...
...
@@ -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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
docs/topics/i18n/timezones.txt
Dosyayı görüntüle @
26a92619
...
...
@@ -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 %}
<form action="{% url 'set_timezone' %}" method="POST">
{% csrf_token %}
<label for="timezone">Time zone:</label>
...
...
@@ -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
----------------
...
...
docs/topics/i18n/translation.txt
Dosyayı görüntüle @
26a92619
...
...
@@ -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 <USE_I18N>` 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,27 +810,28 @@ the second will always be in English.
Other tags
----------
Each ``RequestContext`` has access to three translation-specific variables:
These tags also require a ``{% load i18n %}``.
* ``
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).
* ``
{% 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).
* ``LANGUAGE_CODE`` is the current user's preferred language, as a string.
Example: ``en-us``. (See :ref:`how-django-discovers-language-preference`.)
* ``{% 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`.)
* ``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.
* ``{% 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 don't use the ``RequestContext`` extension, you can get those values with
three tags::
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.
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_current_language_bidi as LANGUAGE_BIDI %}
.. versionchanged:: 1.8
These tags also require a ``{% load i18n %}``
.
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,
...
...
@@ -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 %}
<form action="{% url 'set_language' %}" method="post">
{% csrf_token %}
<input name="next" type="hidden" value="{{ redirect_to }}" />
<select name="language">
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected="selected"{% endif %}>
...
...
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