mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #24149 -- Normalized tuple settings to lists.
This commit is contained in:
parent
570912a97d
commit
9ec8aa5e5d
120 changed files with 612 additions and 616 deletions
|
@ -52,13 +52,13 @@ all of its authentication backends. If the first authentication method fails,
|
|||
Django tries the second one, and so on, until all backends have been attempted.
|
||||
|
||||
The list of authentication backends to use is specified in the
|
||||
:setting:`AUTHENTICATION_BACKENDS` setting. This should be a tuple of Python
|
||||
:setting:`AUTHENTICATION_BACKENDS` setting. This should be a list of Python
|
||||
path names that point to Python classes that know how to authenticate. These
|
||||
classes can be anywhere on your Python path.
|
||||
|
||||
By default, :setting:`AUTHENTICATION_BACKENDS` is set to::
|
||||
|
||||
('django.contrib.auth.backends.ModelBackend',)
|
||||
['django.contrib.auth.backends.ModelBackend']
|
||||
|
||||
That's the basic authentication backend that checks the Django users database
|
||||
and queries the built-in permissions. It does not provide protection against
|
||||
|
|
|
@ -49,7 +49,7 @@ first in the list.
|
|||
|
||||
The default for :setting:`PASSWORD_HASHERS` is::
|
||||
|
||||
PASSWORD_HASHERS = (
|
||||
PASSWORD_HASHERS = [
|
||||
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
|
||||
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
|
||||
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
|
||||
|
@ -57,7 +57,7 @@ The default for :setting:`PASSWORD_HASHERS` is::
|
|||
'django.contrib.auth.hashers.SHA1PasswordHasher',
|
||||
'django.contrib.auth.hashers.MD5PasswordHasher',
|
||||
'django.contrib.auth.hashers.CryptPasswordHasher',
|
||||
)
|
||||
]
|
||||
|
||||
This means that Django will use PBKDF2_ to store all passwords, but will support
|
||||
checking passwords stored with PBKDF2SHA1, bcrypt_, SHA1_, etc. The next few
|
||||
|
@ -83,7 +83,7 @@ To use Bcrypt as your default storage algorithm, do the following:
|
|||
2. Modify :setting:`PASSWORD_HASHERS` to list ``BCryptSHA256PasswordHasher``
|
||||
first. That is, in your settings file, you'd put::
|
||||
|
||||
PASSWORD_HASHERS = (
|
||||
PASSWORD_HASHERS = [
|
||||
'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
|
||||
'django.contrib.auth.hashers.BCryptPasswordHasher',
|
||||
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
|
||||
|
@ -91,7 +91,7 @@ To use Bcrypt as your default storage algorithm, do the following:
|
|||
'django.contrib.auth.hashers.SHA1PasswordHasher',
|
||||
'django.contrib.auth.hashers.MD5PasswordHasher',
|
||||
'django.contrib.auth.hashers.CryptPasswordHasher',
|
||||
)
|
||||
]
|
||||
|
||||
(You need to keep the other entries in this list, or else Django won't
|
||||
be able to upgrade passwords; see below).
|
||||
|
@ -154,7 +154,7 @@ default PBKDF2 algorithm:
|
|||
|
||||
2. Add your new hasher as the first entry in :setting:`PASSWORD_HASHERS`::
|
||||
|
||||
PASSWORD_HASHERS = (
|
||||
PASSWORD_HASHERS = [
|
||||
'myproject.hashers.MyPBKDF2PasswordHasher',
|
||||
'django.contrib.auth.hashers.PBKDF2PasswordHasher',
|
||||
'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
|
||||
|
@ -163,7 +163,7 @@ default PBKDF2 algorithm:
|
|||
'django.contrib.auth.hashers.SHA1PasswordHasher',
|
||||
'django.contrib.auth.hashers.MD5PasswordHasher',
|
||||
'django.contrib.auth.hashers.CryptPasswordHasher',
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
That's it -- now your Django install will use more iterations when it
|
||||
|
|
|
@ -437,11 +437,11 @@ entire site. You'll need to add
|
|||
``'django.middleware.cache.FetchFromCacheMiddleware'`` to your
|
||||
:setting:`MIDDLEWARE_CLASSES` setting, as in this example::
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
MIDDLEWARE_CLASSES = [
|
||||
'django.middleware.cache.UpdateCacheMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.cache.FetchFromCacheMiddleware',
|
||||
)
|
||||
]
|
||||
|
||||
.. note::
|
||||
|
||||
|
|
|
@ -70,11 +70,11 @@ For example, if the models for your application live in the module
|
|||
application by the :djadmin:`manage.py startapp <startapp>` script),
|
||||
:setting:`INSTALLED_APPS` should read, in part::
|
||||
|
||||
INSTALLED_APPS = (
|
||||
INSTALLED_APPS = [
|
||||
#...
|
||||
'myapp',
|
||||
#...
|
||||
)
|
||||
]
|
||||
|
||||
When you add new apps to :setting:`INSTALLED_APPS`, be sure to run
|
||||
:djadmin:`manage.py migrate <migrate>`, optionally making migrations
|
||||
|
|
|
@ -132,8 +132,8 @@ handler* -- a small class that handles file data as it gets uploaded. Upload
|
|||
handlers are initially defined in the :setting:`FILE_UPLOAD_HANDLERS` setting,
|
||||
which defaults to::
|
||||
|
||||
("django.core.files.uploadhandler.MemoryFileUploadHandler",
|
||||
"django.core.files.uploadhandler.TemporaryFileUploadHandler",)
|
||||
["django.core.files.uploadhandler.MemoryFileUploadHandler",
|
||||
"django.core.files.uploadhandler.TemporaryFileUploadHandler"]
|
||||
|
||||
Together :class:`MemoryFileUploadHandler` and
|
||||
:class:`TemporaryFileUploadHandler` provide Django's default file upload
|
||||
|
|
|
@ -20,21 +20,21 @@ Activating middleware
|
|||
=====================
|
||||
|
||||
To activate a middleware component, add it to the
|
||||
:setting:`MIDDLEWARE_CLASSES` tuple in your Django settings.
|
||||
:setting:`MIDDLEWARE_CLASSES` list in your Django settings.
|
||||
|
||||
In :setting:`MIDDLEWARE_CLASSES`, each middleware component is represented by
|
||||
a string: the full Python path to the middleware's class name. For example,
|
||||
here's the default value created by :djadmin:`django-admin startproject
|
||||
<startproject>`::
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
MIDDLEWARE_CLASSES = [
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
)
|
||||
]
|
||||
|
||||
A Django installation doesn't require any middleware —
|
||||
:setting:`MIDDLEWARE_CLASSES` can be empty, if you'd like — but it's strongly
|
||||
|
|
|
@ -848,7 +848,7 @@ information for a list of languages (e.g. active languages as specified in
|
|||
view <set_language-redirect-view>` for an example of how to display a language
|
||||
selector using ``{% get_language_info_list %}``.
|
||||
|
||||
In addition to :setting:`LANGUAGES` style nested tuples,
|
||||
In addition to :setting:`LANGUAGES` style list of tuples,
|
||||
``{% get_language_info_list %}`` supports simple lists of language codes.
|
||||
If you do this in your view:
|
||||
|
||||
|
@ -1684,11 +1684,11 @@ matters, you should follow these guidelines:
|
|||
|
||||
For example, your :setting:`MIDDLEWARE_CLASSES` might look like this::
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
MIDDLEWARE_CLASSES = [
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
)
|
||||
]
|
||||
|
||||
(For more on middleware, see the :doc:`middleware documentation
|
||||
</topics/http/middleware>`.)
|
||||
|
@ -1734,10 +1734,10 @@ Notes:
|
|||
languages (because your application doesn't provide all those languages),
|
||||
set :setting:`LANGUAGES` to a list of languages. For example::
|
||||
|
||||
LANGUAGES = (
|
||||
LANGUAGES = [
|
||||
('de', _('German')),
|
||||
('en', _('English')),
|
||||
)
|
||||
]
|
||||
|
||||
This example restricts languages that are available for automatic
|
||||
selection to German and English (and any sublanguage, like de-ch or
|
||||
|
@ -1752,10 +1752,10 @@ Notes:
|
|||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
LANGUAGES = (
|
||||
LANGUAGES = [
|
||||
('de', _('German')),
|
||||
('en', _('English')),
|
||||
)
|
||||
]
|
||||
|
||||
Once ``LocaleMiddleware`` determines the user's preference, it makes this
|
||||
preference available as ``request.LANGUAGE_CODE`` for each
|
||||
|
|
|
@ -320,9 +320,9 @@ design. If during your tests you are authenticating many users, you may want
|
|||
to use a custom settings file and set the :setting:`PASSWORD_HASHERS` setting
|
||||
to a faster hashing algorithm::
|
||||
|
||||
PASSWORD_HASHERS = (
|
||||
PASSWORD_HASHERS = [
|
||||
'django.contrib.auth.hashers.MD5PasswordHasher',
|
||||
)
|
||||
]
|
||||
|
||||
Don't forget to also include in :setting:`PASSWORD_HASHERS` any hashing
|
||||
algorithm used in fixtures, if any.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue