Pengaturan¶
Peringatan
Be careful when you override settings, especially when the default value
is a non-empty list or dictionary, such as STATICFILES_FINDERS
.
Make sure you keep the components required by the features of Django you
wish to use.
Pengaturan Inti¶
Here's a list of settings available in Django core and their default values. Settings provided by contrib apps are listed below, followed by a topical index of the core settings. For introductory material, see the settings topic guide.
ABSOLUTE_URL_OVERRIDES
¶
Awalan: {}
(Kamus kosong)
A dictionary mapping "app_label.model_name"
strings to functions that take
a model object and return its URL. This is a way of inserting or overriding
get_absolute_url()
methods on a per-installation basis. Example:
ABSOLUTE_URL_OVERRIDES = {
"blogs.blog": lambda o: "/blogs/%s/" % o.slug,
"news.story": lambda o: "/stories/%s/%s/" % (o.pub_year, o.slug),
}
The model name used in this setting should be all lowercase, regardless of the case of the actual model class name.
ADMINS
¶
Awalan: {}
(Daftar kosong)
A list of all the people who get code error notifications. When
DEBUG=False
and AdminEmailHandler
is configured in LOGGING
(done by default), Django emails these
people the details of exceptions raised in the request/response cycle.
Setiap barang dalam daftar harus berupa tuple dari (Nama lengkap, alamat surel). Contoh:
[("John", "[email protected]"), ("Mary", "[email protected]")]
ALLOWED_HOSTS
¶
Awalan: {}
(Daftar kosong)
A list of strings representing the host/domain names that this Django site can serve. This is a security measure to prevent HTTP Host header attacks, which are possible even under many seemingly-safe web server configurations.
Nilai-nilai dalam daftar ini dapat berupa sepenuhnya nama-nama berkualitas (misalnya 'www.example.com'
), dalam kasus mereka akan cocok terhadap kepala Host
permintaan tepatnya (kurang-peka-kasus, tidak termasuk port). Sebuah nilai dimulai dengan titik dapat digunakan sebagai wildcard subranah: '.example.com'
akan cocok example.com
, www.example.com
, dan subranah lainnya dari example.com
. Nilai dari '*'
akan cocok apapun; dalam kasus ini anda bertanggung jawab untuk menyediakan pengesahan anda sendiri dari kepala Host
(mungkin dalam sebuah middleware; jika demikian middleware ini harus didaftarkan dahulu dalam MIDDLEWARE
).
Django also allows the fully qualified domain name (FQDN) of any entries.
Some browsers include a trailing dot in the Host
header which Django
strips when performing host validation.
Jika kepala Host
(atau X-Forwarded-Host
jika USE_X_FORWARDED_HOST
diadakan) tidak cocok nilai apapun dalam daftar ini, metode django.http.HttpRequest.get_host()
akan memunculkan SuspiciousOperation
.
When DEBUG
is True
and ALLOWED_HOSTS
is empty, the host
is validated against ['.localhost', '127.0.0.1', '[::1]']
.
ALLOWED_HOSTS
adalah juga checked when running tests.
This validation only applies via get_host()
;
if your code accesses the Host
header directly from request.META
you
are bypassing this security protection.
APPEND_SLASH
¶
Awal: True
Ketika disetel menjadi True
, jika URL diminta tidak cocok salah satu dari pola dalam URLconf dan itu tidak berakhir dalam sebuah garis miring, sebuah pengalihan HTTP diterbitkan ke URL sama dengan sebuah garis miring ditambahkan. Catat bahwa pengalihan mungkin menyebabkan data apapun diajukan dalam sebuah permintaan POST menjadi hilang.
Pengaturan APPEND_SLASH
hanya digunakan jika CommonMiddleware
dipasang (lihat Middleware). Lihat juga PREPEND_WWW
.
CACHES
¶
Awal:
{
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
}
}
A dictionary containing the settings for all caches to be used with Django. It is a nested dictionary whose contents maps cache aliases to a dictionary containing the options for an individual cache.
The CACHES
setting must configure a default
cache;
any number of additional caches may also be specified. If you
are using a cache backend other than the local memory cache, or
you need to define multiple caches, other options will be required.
The following cache options are available.
BACKEND
¶
Awalan: ''
(String kosong)
Backend cache untuk digunakan. Backend cache siap-pakai adalah:
'django.core.cache.backends.db.DatabaseCache'
'django.core.cache.backends.dummy.DummyCache'
'django.core.cache.backends.filebased.FileBasedCache'
'django.core.cache.backends.locmem.LocMemCache'
'django.core.cache.backends.memcached.PyMemcacheCache'
'django.core.cache.backends.memcached.PyLibMCCache'
'django.core.cache.backends.redis.RedisCache'
You can use a cache backend that doesn't ship with Django by setting
BACKEND
to a fully-qualified path of a cache
backend class (i.e. mypackage.backends.whatever.WhateverCache
).
KEY_FUNCTION
¶
A string containing a dotted path to a function (or any callable) that defines how to compose a prefix, version and key into a final cache key. The default implementation is equivalent to the function:
def make_key(key, key_prefix, version):
return ":".join([key_prefix, str(version), key])
Anda dapat menggunakan fungsi kunci apapun anda inginkan, selama itu mempunyai tanda tangan argumen sama.
Lihat cache documentation untuk informasi lebih.
KEY_PREFIX
¶
Awalan: ''
(String kosong)
Sebuah string yang akan otomatis disertakan (didahulukan secara awalan) untuk memangguk semua kunci penyimpanan sementara digunakan oleh peladen Django.
Lihat cache documentation untuk informasi lebih.
LOCATION
¶
Awalan: ''
(String kosong)
The location of the cache to use. This might be the directory for a file system cache, a host and port for a memcache server, or an identifying name for a local memory cache. e.g.:
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.filebased.FileBasedCache",
"LOCATION": "/var/tmp/django_cache",
}
}
OPTIONS
¶
Awalan: None
Parameter tambahan untuk dilewatkan ke backend penyimpanan sementara. Parameter tersedia beragam bergantung pada backend penyimpanan sementara anda.
Beberapa informasi pada parameter tersedia dapat ditemukan dalam dokumentasi cache arguments. Untuk informasi lebih, obrolkan backend modul dokumentasi sendiri anda.
TIMEOUT
¶
Awalan: 300
The number of seconds before a cache entry is considered stale. If the value of
this setting is None
, cache entries will not expire. A value of 0
causes keys to immediately expire (effectively "don't cache").
VERSION
¶
Awalan: 1
Nomor versi awalan untuk kunci-kunci penyimpanan sementara dibangkitkan oleh peladen Django.
Lihat the cache documentation untuk informasi lebih.
CACHE_MIDDLEWARE_ALIAS
¶
Awalan: 'default'
hubungan cache untuk digunakan untuk cache middleware.
CACHE_MIDDLEWARE_KEY_PREFIX
¶
Awalan: ''
(String kosong)
Sebuah string yang akan diawalan pada kunci penyimpanan sementara dibangkitkan oleh cache middleware. Awalan ini dipadukan dengan pengaturan KEY_PREFIX
setting; itu tidak menggantinya.
CACHE_MIDDLEWARE_SECONDS
¶
Awalan: 600
The default integer number of seconds to cache a page for the cache middleware.
CSRF_USE_SESSIONS
¶
Awal: False
Apakah menyimpan token CSRF dalam sesi pengguna daripada dalam sebuah kue. Itu membutuhkan penggunaan django.contrib.sessions
.
Menyimpan token CSRF dalam sebuah kue (awalan Django) adalah aman, tetapi menyimpan itu dalam sesi adalah praktik umum dalam kerangka kerja karingan lain dan oleh akrena itu terkadan diminta oleh pemeriksa keamanan.
Since the default error views require the CSRF token,
SessionMiddleware
must appear in
MIDDLEWARE
before any middleware that may raise an exception to
trigger an error view (such as PermissionDenied
)
if you're using CSRF_USE_SESSIONS
. See Pengurutan middleware.
CSRF_FAILURE_VIEW
¶
Awalan: 'django.views.csrf.csrf_failure'
Sebuah jalur bertitik untuk melihat fungsi untuk digunakan ketika permintaan datang ditolak oleh CSRF protection. Fungsi harus memiliki tanda tangan ini:
def csrf_failure(request, reason=""): ...
dimana reason
adalah pesan pendek (diperuntukkan untuk pengembang atau pencatat, bukan untuk pengguna akhir) menunjukkan alasan permintaan telah ditolak. Itu harus mengembalikan sebuah HttpResponseForbidden
.
django.views.csrf.csrf_failure()
menerima sebuah tambahan parameter template_name
yang awalan pada '403_csrf.html'
. Jika sebuah cetakan dengan nama yang ada, itu akan digunakan membangun halaman.
CSRF_HEADER_NAME
¶
Awalan: 'HTTP_X_CSRFTOKEN'
Nama dari kepala peminta digunakan untuk autentifikasi CSRF.
As with other HTTP headers in request.META
, the header name received from
the server is normalized by converting all characters to uppercase, replacing
any hyphens with underscores, and adding an 'HTTP_'
prefix to the name.
For example, if your client sends a 'X-XSRF-TOKEN'
header, the setting
should be 'HTTP_X_XSRF_TOKEN'
.
CSRF_TRUSTED_ORIGINS
¶
Awalan: {}
(Daftar kosong)
A list of trusted origins for unsafe requests (e.g. POST
).
For requests that include the Origin
header, Django's CSRF protection
requires that header match the origin present in the Host
header.
For a secure
unsafe
request that doesn't include the Origin
header, the request must have a
Referer
header that matches the origin present in the Host
header.
These checks prevent, for example, a POST
request from
subdomain.example.com
from succeeding against api.example.com
. If you
need cross-origin unsafe requests, continuing the example, add
'https://subdomain.example.com'
to this list (and/or http://...
if
requests originate from an insecure page).
The setting also supports subdomains, so you could add
'https://*.example.com'
, for example, to allow access from all subdomains
of example.com
.
DATABASES
¶
Awalan: {}
(Kamus kosong)
Sebuah dictionary mengandung pengaturan semua basisdata utnuk digunakan dengan Django. itu adalah dictionary bersarang yang isinya memetakan sebuah nama lain basisdata ke sebuah dictionary pilihan untuk sebuah basisdata sendiri.
Pengaturan DATABASES
harus mengkonfigurasi sebuah basisdata default
; angka apapun dari basisdata tambahan mungkin juga ditentukan.
Kemungkinan berkas pengaturan sederhana adalah untuk pengaturan basisdata-tunggal menggunakan SQLite. Ini dapat dikonfigurasi menggunakan berikut:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": "mydatabase",
}
}
When connecting to other database backends, such as MariaDB, MySQL, Oracle, or
PostgreSQL, additional connection parameters will be required. See
the ENGINE
setting below on how to specify
other database types. This example is for PostgreSQL:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "mydatabase",
"USER": "mydatabaseuser",
"PASSWORD": "mypassword",
"HOST": "127.0.0.1",
"PORT": "5432",
}
}
Pilihan paling dalam berikut yang mungkin dibutuhkan untuk konfigurasi lebih lengkap tersedia:
ATOMIC_REQUESTS
¶
Awal: False
Setel ini menjadi True
untuk membungkus setiap tampilan dalam transaksi pada basisdata ini. Lihat Mengikat transaksi pada permintaan HTTP.
AUTOCOMMIT
¶
Awal: True
Setel ini menjadi False
jika anda ingin disable Django's transaction management dan menerapkan milik anda sendiri.
ENGINE
¶
Awalan: ''
(String kosong)
Backend basisdata untuk digunakan. Backend basisdata siap-pakai adalah:
'django.db.backends.postgresql'
'django.db.backends.mysql'
'django.db.backends.sqlite3'
'django.db.backends.oracle'
Anda dapat menggunakan backend basisdata yang tidak dikirim dengan Django dengan mengatur ENGINE
pada jalur sepenuhnya memenuhi syarat (yaitu mypackage.backends.whatever
).
HOST
¶
Awalan: ''
(String kosong)
Rumah mana digunakan ketika menghubungkan ke basisdata. Sebuah string kosong berarti localhost. Tidak digunakan dengan SQLite.
Jika nilai ini dimulai dengan garis depan ('/'
) dan anda sedang menggunakan MySQL, MySQLakan terhubung melalui sebuah soket unix pada soket yang ditentukan. Sebagi contoh:
"HOST": "/var/run/mysql"
Jika anda menggunakan MySQL dan nilai ini tidak dimulai dengan garis miring depan, kemudian nilai ini dianggap menjadi rumah.
Jika anda sedang menggunakan PostgreSQL, secara awalan (HOST
kosong), hubungan ke baisdata selesai melalui soket ranah UNIX (baris-baris 'local' dalam pg_hba.conf
). Jika soket ranah anda bukan tempat standar, gunakan nilai sama dari unix_socket_directory
dari postgresql.conf
. Jika anda ingin berhubungan melalui soket TCP, setel HOST
pada 'localhost' atau '127.0.0.1' (baris-baris 'host' dalam pg_hba.conf
). Pada Windows, anda harus selalu menentukan HOST
, ketika soket ranah UNIX tidak tersedia.
NAME
¶
Awalan: ''
(String kosong)
Nama dari basisdata untuk digunakan. Untuk SQLite, itu adalah jalur penuh pada berkas basisdata. Ketika menentukan jalur, selalu gunakan garis miring depan, bahkan pada Windows (misalnya C:/homes/user/mysite/sqlite3.db`).
CONN_MAX_AGE
¶
Awal: 0
The lifetime of a database connection, as an integer of seconds. Use 0
to
close database connections at the end of each request — Django's historical
behavior — and None
for unlimited persistent database connections.
CONN_HEALTH_CHECKS
¶
Awal: False
If set to True
, existing persistent database connections will be health checked before they are
reused in each request performing database access. If the health check fails,
the connection will be reestablished without failing the request when the
connection is no longer usable but the database server is ready to accept and
serve new connections (e.g. after database server restart closing existing
connections).
OPTIONS
¶
Awalan: {}
(Kamus kosong)
Parameter tambahan digunakan ketika berhubungan ke basisdata. Parameter tersedia beragam bergantung pada backend basisdata anda.
Beberapa informasi pada parameter tersedia dapat ditemukan dalam dokumentasi Database Backends. Untuk informasi lebih, rundingkan dokumentasi modul backend milik anda sendiri.
PASSWORD
¶
Awalan: ''
(String kosong)
Sandi anda gunakan ketika berhubungan ke basisdata. Tidak digunakan dengan SQLite.
PORT
¶
Awalan: ''
(String kosong)
Port digunakan ketika berhubungan ke basisdata. Sebuah string kosong berarti port awalan. Bukan digunakan dengan SQLite.
TIME_ZONE
¶
Awalan: None
A string representing the time zone for this database connection or None
.
This inner option of the DATABASES
setting accepts the same values
as the general TIME_ZONE
setting.
When USE_TZ
is True
, reading datetimes from the database
returns aware datetimes with the timezone set to this option's value if not
None
, or to UTC otherwise.
When USE_TZ
is False
, it is an error to set this option.
If the database backend doesn't support time zones (e.g. SQLite, MySQL, Oracle), Django reads and writes datetimes in local time according to this option if it is set and in UTC if it isn't.
Changing the connection time zone changes how datetimes are read from and written to the database.
If Django manages the database and you don't have a strong reason to do otherwise, you should leave this option unset. It's best to store datetimes in UTC because it avoids ambiguous or nonexistent datetimes during daylight saving time changes. Also, receiving datetimes in UTC keeps datetime arithmetic simple — there's no need to consider potential offset changes over a DST transition.
If you're connecting to a third-party database that stores datetimes in a local time rather than UTC, then you must set this option to the appropriate time zone. Likewise, if Django manages the database but third-party systems connect to the same database and expect to find datetimes in local time, then you must set this option.
If the database backend supports time zones (e.g., PostgreSQL), then the database connection's time zone is set to this value.
Although setting the
TIME_ZONE
option is very rarely needed, there are situations where it becomes necessary. Specifically, it's recommended to match the generalTIME_ZONE
setting when dealing with raw queries involving date/time functions like PostgreSQL'sdate_trunc()
orgenerate_series()
, especially when generating time-based series that transition daylight savings.This value can be changed at any time, the database will handle the conversion of datetimes to the configured time zone.
However, this has a downside: receiving all datetimes in local time makes datetime arithmetic more tricky — you must account for possible offset changes over DST transitions.
Consider converting to local time explicitly with
AT TIME ZONE
in raw SQL queries instead of setting theTIME_ZONE
option.
DISABLE_SERVER_SIDE_CURSORS
¶
Awal: False
Setel ini menjadi True
jika anda ingin meniadakan penggunaan kursor sisi-peladen dengan QuerySet.iterator()
. Menggabungkan transaksi dan kursor sisi-peladen menggambarkan kasus penggunaan.
Ini adalah pengaturan tertentu-PostgreSQL.
USER
¶
Awalan: ''
(String kosong)
Username untuk digunakan ketika berhubungan ke basisdata. Tidak digunakan dengan SQLite.
TEST
¶
Awalan: {}
(Kamus kosong)
Sebuah dictionary dari pengaturan untuk percobaan basisdata; untuk rincian lebih tentang pembuatan dan penggunakan percobaan basisdata, lihat Basisdata percobaan.
Ini adalah sebuah contoh dengan konfigurasi basisdata percobaan:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"USER": "mydatabaseuser",
"NAME": "mydatabase",
"TEST": {
"NAME": "mytestdatabase",
},
},
}
Kunci berikut dalam dictionary TEST
tersedia:
CHARSET
¶
Awalan: None
The character set encoding used to create the test database. The value of this string is passed directly through to the database, so its format is backend-specific.
Didukung oleh backend PostgreSQL (postgresql
) dan MySQL (mysql
).
COLLATION
¶
Awalan: None
The collation order to use when creating the test database. This value is passed directly to the backend, so its format is backend-specific.
Hanya didukung untuk backend mysql
(lihat MySQL manual untuk rincian).
DEPENDENCIES
¶
Awalan: ['default']
, untuk semua basisdata selain dari default
, yang tidak mempunyai ketergantungan.
The creation-order dependencies of the database. See the documentation on controlling the creation order of test databases for details.
MIGRATE
¶
Awal: True
When set to False
, migrations won't run when creating the test database.
This is similar to setting None
as a value in MIGRATION_MODULES
,
but for all apps.
MIRROR
¶
Awalan: None
The alias of the database that this database should mirror during
testing. It depends on transactions and therefore must be used within
TransactionTestCase
instead of
TestCase
.
This setting exists to allow for testing of primary/replica (referred to as master/slave by some databases) configurations of multiple databases. See the documentation on testing primary/replica configurations for details.
NAME
¶
Awalan: None
Nama dari basisdata untuk digunakan ketika menjalankan rangkaian percobaan.
If the default value (None
) is used with the SQLite database engine, the
tests will use a memory resident database. For all other database engines the
test database will use the name 'test_' + DATABASE_NAME
.
Lihat Basisdata percobaan.
TEMPLATE
¶
Ini adalah pengaturan tertentu-PostgreSQL.
The name of a template (e.g. 'template0'
) from which to create the test
database.
CREATE_DB
¶
Awal: True
Ini adalah sebuah pengaturan khusus-Oracle.
Jika itu disetel menjadi False
, tablespace percobaan tidak akan otomatis dibuat pada permulaan dari percobaan atau dijatuhkan pada akhir.
CREATE_USER
¶
Awal: True
Ini adalah sebuah pengaturan khusus-Oracle.
Jika ini disetel menjadi False
, percobaan pengguna tidak akan otomatis dibuat pada akhiran dari percobaan dan dijatuhkan pada akhir.
USER
¶
Awalan: None
Ini adalah sebuah pengaturan khusus-Oracle.
Nama pengguna digunakan ketika berhubungan ke basisdata Oracle yang akan digunakan ketika menjalankan percobaan. Jika tidak disediakan, Django akan menggunakan 'test_' + USER
.
PASSWORD
¶
Awalan: None
Ini adalah sebuah pengaturan khusus-Oracle.
The password to use when connecting to the Oracle database that will be used when running tests. If not provided, Django will generate a random password.
ORACLE_MANAGED_FILES
¶
Awal: False
Ini adalah sebuah pengaturan khusus-Oracle.
If set to True
, Oracle Managed Files (OMF) tablespaces will be used.
DATAFILE
and DATAFILE_TMP
will be ignored.
TBLSPACE
¶
Awalan: None
Ini adalah sebuah pengaturan khusus-Oracle.
The name of the tablespace that will be used when running tests. If not
provided, Django will use 'test_' + USER
.
TBLSPACE_TMP
¶
Awalan: None
Ini adalah sebuah pengaturan khusus-Oracle.
The name of the temporary tablespace that will be used when running tests. If
not provided, Django will use 'test_' + USER + '_temp'
.
DATAFILE
¶
Awalan: None
Ini adalah sebuah pengaturan khusus-Oracle.
The name of the datafile to use for the TBLSPACE. If not provided, Django will
use TBLSPACE + '.dbf'
.
DATAFILE_TMP
¶
Awalan: None
Ini adalah sebuah pengaturan khusus-Oracle.
The name of the datafile to use for the TBLSPACE_TMP. If not provided, Django
will use TBLSPACE_TMP + '.dbf'
.
DATAFILE_MAXSIZE
¶
Awalan: '500M'
Ini adalah sebuah pengaturan khusus-Oracle.
Ukuran maksimal yang DATAFILE izinkan untuk tumbuh.
DATAFILE_TMP_MAXSIZE
¶
Awalan: '500M'
Ini adalah sebuah pengaturan khusus-Oracle.
Ukuran maksimal yang DATAFILE_TMP izinkan untuk tumbuh.
DATAFILE_SIZE
¶
Awalan: '50M'
Ini adalah sebuah pengaturan khusus-Oracle.
Ukuran inisial dari DATAFILE.
DATAFILE_TMP_SIZE
¶
Awalan: '50M'
Ini adalah sebuah pengaturan khusus-Oracle.
Ukuran inisial dari DATAFILE_TMP.
DATAFILE_EXTSIZE
¶
Awalan: '25M'
Ini adalah sebuah pengaturan khusus-Oracle.
Jumlah dimana DATAFILE diperpanjang ketika ruang lebih dubutuhkan.
DATAFILE_TMP_EXTSIZE
¶
Awalan: '25M'
Ini adalah sebuah pengaturan khusus-Oracle.
Jumlah dari DATAFILE_TMP diperpanjang ketika ruang lebih dibutuhkan.
DATA_UPLOAD_MAX_MEMORY_SIZE
¶
Awalan: 2621440
(yaitu 2.5 MB).
The maximum size in bytes that a request body may be before a
SuspiciousOperation
(RequestDataTooBig
) is
raised. The check is done when accessing request.body
or request.POST
and is calculated against the total request size excluding any file upload
data. You can set this to None
to disable the check. Applications that are
expected to receive unusually large form posts should tune this setting.
The amount of request data is correlated to the amount of memory needed to process the request and populate the GET and POST dictionaries. Large requests could be used as a denial-of-service attack vector if left unchecked. Since web servers don't typically perform deep request inspection, it's not possible to perform a similar check at that level.
Lihat juga FILE_UPLOAD_MAX_MEMORY_SIZE
.
DATA_UPLOAD_MAX_NUMBER_FIELDS
¶
Awalan: 1000
The maximum number of parameters that may be received via GET or POST before a
SuspiciousOperation
(TooManyFields
) is
raised. You can set this to None
to disable the check. Applications that
are expected to receive an unusually large number of form fields should tune
this setting.
The number of request parameters is correlated to the amount of time needed to process the request and populate the GET and POST dictionaries. Large requests could be used as a denial-of-service attack vector if left unchecked. Since web servers don't typically perform deep request inspection, it's not possible to perform a similar check at that level.
DATA_UPLOAD_MAX_NUMBER_FILES
¶
Default: 100
The maximum number of files that may be received via POST in a
multipart/form-data
encoded request before a
SuspiciousOperation
(TooManyFiles
) is
raised. You can set this to None
to disable the check. Applications that
are expected to receive an unusually large number of file fields should tune
this setting.
The number of accepted files is correlated to the amount of time and memory needed to process the request. Large requests could be used as a denial-of-service attack vector if left unchecked. Since web servers don't typically perform deep request inspection, it's not possible to perform a similar check at that level.
DATABASE_ROUTERS
¶
Awalan: {}
(Daftar kosong)
The list of routers that will be used to determine which database to use when performing a database query.
Lihat dokumentasi pada automatic database routing in multi database configurations.
DATE_FORMAT
¶
Awalan: 'N j, Y'
(misalnya Feb. 4, 2003
)
The default formatting to use for displaying date fields in any part of the
system. Note that the locale-dictated format has higher precedence and will be
applied instead. See allowed date format strings
.
Lihat juga DATETIME_FORMAT
, TIME_FORMAT
dan SHORT_DATE_FORMAT
.
DATE_INPUT_FORMATS
¶
Awal:
[
"%Y-%m-%d", # '2006-10-25'
"%m/%d/%Y", # '10/25/2006'
"%m/%d/%y", # '10/25/06'
"%b %d %Y", # 'Oct 25 2006'
"%b %d, %Y", # 'Oct 25, 2006'
"%d %b %Y", # '25 Oct 2006'
"%d %b, %Y", # '25 Oct, 2006'
"%B %d %Y", # 'October 25 2006'
"%B %d, %Y", # 'October 25, 2006'
"%d %B %Y", # '25 October 2006'
"%d %B, %Y", # '25 October, 2006'
]
A list of formats that will be accepted when inputting data on a date field.
Formats will be tried in order, using the first valid one. Note that these
format strings use Python's datetime module syntax, not the format strings from the date
template filter.
The locale-dictated format has higher precedence and will be applied instead.
Lihat juga DATETIME_INPUT_FORMATS
dan TIME_INPUT_FORMATS
.
DATETIME_FORMAT
¶
Awalan: 'N j, Y, P'
(misalnya Feb. 4, 2003, 4 p.m.
)
The default formatting to use for displaying datetime fields in any part of the
system. Note that the locale-dictated format has higher precedence and will be
applied instead. See allowed date format strings
.
Lihat juga DATE_FORMAT
, TIME_FORMAT
dan SHORT_DATETIME_FORMAT
.
DATETIME_INPUT_FORMATS
¶
Awal:
[
"%Y-%m-%d %H:%M:%S", # '2006-10-25 14:30:59'
"%Y-%m-%d %H:%M:%S.%f", # '2006-10-25 14:30:59.000200'
"%Y-%m-%d %H:%M", # '2006-10-25 14:30'
"%m/%d/%Y %H:%M:%S", # '10/25/2006 14:30:59'
"%m/%d/%Y %H:%M:%S.%f", # '10/25/2006 14:30:59.000200'
"%m/%d/%Y %H:%M", # '10/25/2006 14:30'
"%m/%d/%y %H:%M:%S", # '10/25/06 14:30:59'
"%m/%d/%y %H:%M:%S.%f", # '10/25/06 14:30:59.000200'
"%m/%d/%y %H:%M", # '10/25/06 14:30'
]
A list of formats that will be accepted when inputting data on a datetime
field. Formats will be tried in order, using the first valid one. Note that
these format strings use Python's datetime module syntax, not the format strings from the date
template filter. Date-only formats are not included as datetime fields will
automatically try DATE_INPUT_FORMATS
in last resort.
The locale-dictated format has higher precedence and will be applied instead.
Lihat juga DATE_INPUT_FORMATS
dan TIME_INPUT_FORMATS
.
DEBUG
¶
Awal: False
Boolean yang menyalakan/mematikan suasana mencari kesalahan.
Jangan pernah menyebarkan situs kedalam kedalam produksi dengan DEBUG
menyala.
One of the main features of debug mode is the display of detailed error pages.
If your app raises an exception when DEBUG
is True
, Django will
display a detailed traceback, including a lot of metadata about your
environment, such as all the currently defined Django settings (from
settings.py
).
As a security measure, Django will not include settings that might be
sensitive, such as SECRET_KEY
. Specifically, it will exclude any
setting whose name includes any of the following:
'API'
'KEY'
'PASS'
'SECRET'
'SIGNATURE'
'TOKEN'
Note that these are partial matches. 'PASS'
will also match PASSWORD,
just as 'TOKEN'
will also match TOKENIZED and so on.
Still, note that there are always going to be sections of your debug output that are inappropriate for public consumption. File paths, configuration options and the like all give attackers extra information about your server.
It is also important to remember that when running with DEBUG
turned on, Django will remember every SQL query it executes. This is useful
when you're debugging, but it'll rapidly consume memory on a production server.
Finally, if DEBUG
is False
, you also need to properly set
the ALLOWED_HOSTS
setting. Failing to do so will result in all
requests being returned as "Bad Request (400)".
Catatan
The default settings.py
file created by django-admin
startproject
sets DEBUG = True
for convenience.
DEBUG_PROPAGATE_EXCEPTIONS
¶
Awal: False
If set to True
, Django's exception handling of view functions
(handler500
, or the debug view if DEBUG
is True
) and logging of 500 responses (django.request) is
skipped and exceptions propagate upward.
This can be useful for some test setups. It shouldn't be used on a live site unless you want your web server (instead of Django) to generate "Internal Server Error" responses. In that case, make sure your server doesn't show the stack trace or other sensitive information in the response.
DECIMAL_SEPARATOR
¶
Awalan: '.'
(Titik)
Pemisah desimal awalan digunakan ketika membentuk angka desimal.
Note that the locale-dictated format has higher precedence and will be applied instead.
Lihat juga NUMBER_GROUPING
, THOUSAND_SEPARATOR
dan USE_THOUSAND_SEPARATOR
.
DEFAULT_AUTO_FIELD
¶
Awalan: '
django.db.models.AutoField
'
Default primary key field type to use for models that don't have a field with
primary_key=True
.
DEFAULT_CHARSET
¶
Awalan: 'utf-8'
Default charset to use for all HttpResponse
objects, if a MIME type isn't
manually specified. Used when constructing the Content-Type
header.
DEFAULT_EXCEPTION_REPORTER
¶
Awalan: '
django.views.debug.ExceptionReporter
'
Default exception reporter class to be used if none has been assigned to the
HttpRequest
instance yet. See
Penyesuaian laporan kesalahan.
DEFAULT_EXCEPTION_REPORTER_FILTER
¶
Awalan: '
django.views.debug.SafeExceptionReporterFilter
'
Default exception reporter filter class to be used if none has been assigned to
the HttpRequest
instance yet.
See Filtering error reports.
DEFAULT_FROM_EMAIL
¶
Awalan: 'webmaster@localhost'
Default email address for automated correspondence from the site manager(s).
This address is used in the From:
header of outgoing emails and can take
any format valid in the chosen email sending protocol.
This doesn't affect error messages sent to ADMINS
and
MANAGERS
. See SERVER_EMAIL
for that.
DEFAULT_INDEX_TABLESPACE
¶
Awalan: ''
(String kosong)
Tablespace awalan digunakan untuk pengindeksan pada bidang yang belum ditentukan, jika backend mendukung itu (lihat Tablespaces).
DEFAULT_TABLESPACE
¶
Awalan: ''
(String kosong)
Tablespace awalan digunakan untuk model yang belum ditentukan, jika backend mendukung itu (lihat Tablespaces).
DISALLOWED_USER_AGENTS
¶
Awalan: {}
(Daftar kosong)
List of compiled regular expression objects representing User-Agent strings
that are not allowed to visit any page, systemwide. Use this for bots/crawlers.
This is only used if CommonMiddleware
is installed (see
Middleware).
EMAIL_BACKEND
¶
Awalan: '
django.core.mail.backends.smtp.EmailBackend
'
The backend to use for sending emails. For the list of available backends see Backend email.
EMAIL_FILE_PATH
¶
Awalan: Tidak ditentukan
The directory used by the file email backend to store output files.
EMAIL_HOST
¶
Awalan: 'localhost'
Rumah digunakan untuk mengirim surel.
Lihat juga EMAIL_PORT
.
EMAIL_HOST_PASSWORD
¶
Awalan: ''
(String kosong)
Password to use for the SMTP server defined in EMAIL_HOST
. This
setting is used in conjunction with EMAIL_HOST_USER
when
authenticating to the SMTP server. If either of these settings is empty,
Django won't attempt authentication.
Lihat juga EMAIL_HOST_USER
.
EMAIL_HOST_USER
¶
Awalan: ''
(String kosong)
Nama pengguna untuk digunakan pada peladen SMTP ditentukan dalam EMAIL_HOST
. Jika kosong, Django tidak akan berusaha mengecek.
Lihat juga EMAIL_HOST_PASSWORD
.
EMAIL_PORT
¶
Awalan: 25
Port digunakan untuk peladen SMTP ditentukan dalam EMAIL_HOST
.
EMAIL_SUBJECT_PREFIX
¶
Awalan: '[Django] '
Subject-line prefix for email messages sent with django.core.mail.mail_admins
or django.core.mail.mail_managers
. You'll probably want to include the
trailing space.
EMAIL_USE_LOCALTIME
¶
Awal: False
Apakah mengirim kepala Date
SMTP dari pesan surel dalam zona waktu lokal (True
) atau dalam UTC (False
).
EMAIL_USE_TLS
¶
Awal: False
Whether to use a TLS (secure) connection when talking to the SMTP server.
This is used for explicit TLS connections, generally on port 587. If you are
experiencing hanging connections, see the implicit TLS setting
EMAIL_USE_SSL
.
EMAIL_USE_SSL
¶
Awal: False
Whether to use an implicit TLS (secure) connection when talking to the SMTP
server. In most email documentation this type of TLS connection is referred
to as SSL. It is generally used on port 465. If you are experiencing problems,
see the explicit TLS setting EMAIL_USE_TLS
.
Note that EMAIL_USE_TLS
/EMAIL_USE_SSL
are mutually
exclusive, so only set one of those settings to True
.
EMAIL_SSL_CERTFILE
¶
Awalan: None
If EMAIL_USE_SSL
or EMAIL_USE_TLS
is True
, you can
optionally specify the path to a PEM-formatted certificate chain file to use
for the SSL connection.
EMAIL_SSL_KEYFILE
¶
Awalan: None
If EMAIL_USE_SSL
or EMAIL_USE_TLS
is True
, you can
optionally specify the path to a PEM-formatted private key file to use for the
SSL connection.
Note that setting EMAIL_SSL_CERTFILE
and EMAIL_SSL_KEYFILE
doesn't result in any certificate checking. They're passed to the underlying SSL
connection. Please refer to the documentation of Python's
ssl.SSLContext.wrap_socket()
function for details on how the
certificate chain file and private key file are handled.
EMAIL_TIMEOUT
¶
Awalan: None
Menentukan waktu habis dalam detik untuk memblok tindakan seperti usaha berhubungan.
FILE_UPLOAD_HANDLERS
¶
Awal:
[
"django.core.files.uploadhandler.MemoryFileUploadHandler",
"django.core.files.uploadhandler.TemporaryFileUploadHandler",
]
A list of handlers to use for uploading. Changing this setting allows complete customization -- even replacement -- of Django's upload process.
Lihat Mengelola berkas untuk rincian.
FILE_UPLOAD_MAX_MEMORY_SIZE
¶
Awalan: 2621440
(yaitu 2.5 MB).
The maximum size (in bytes) that an upload will be before it gets streamed to the file system. See Mengelola berkas for details.
Lihat juga DATA_UPLOAD_MAX_MEMORY_SIZE
.
FILE_UPLOAD_DIRECTORY_PERMISSIONS
¶
Awalan: None
The numeric mode to apply to directories created in the process of uploading files.
This setting also determines the default permissions for collected static
directories when using the collectstatic
management command. See
collectstatic
for details on overriding it.
This value mirrors the functionality and caveats of the
FILE_UPLOAD_PERMISSIONS
setting.
FILE_UPLOAD_PERMISSIONS
¶
Awalan: 0o644
The numeric mode (i.e. 0o644
) to set newly uploaded files to. For
more information about what these modes mean, see the documentation for
os.chmod()
.
If None
, you'll get operating-system dependent behavior. On most platforms,
temporary files will have a mode of 0o600
, and files saved from memory will
be saved using the system's standard umask.
For security reasons, these permissions aren't applied to the temporary files
that are stored in FILE_UPLOAD_TEMP_DIR
.
This setting also determines the default permissions for collected static files
when using the collectstatic
management command. See
collectstatic
for details on overriding it.
Peringatan
Always prefix the mode with 0o
.
If you're not familiar with file modes, please note that the 0o
prefix
is very important: it indicates an octal number, which is the way that
modes must be specified. If you try to use 644
, you'll get totally
incorrect behavior.
FILE_UPLOAD_TEMP_DIR
¶
Awalan: None
The directory to store data to (typically files larger than
FILE_UPLOAD_MAX_MEMORY_SIZE
) temporarily while uploading files.
If None
, Django will use the standard temporary directory for the operating
system. For example, this will default to /tmp
on *nix-style operating
systems.
Lihat Mengelola berkas untuk rincian.
FIRST_DAY_OF_WEEK
¶
Awalan: 0
(Minggu)
A number representing the first day of the week. This is especially useful when displaying a calendar. This value is only used when not using format internationalization, or when a format cannot be found for the current locale.
Nilai harus berupa integer 0 sampai 6, dimana 0 berarti Minggu, 1 berarti Senin dan seterusnya.
FIXTURE_DIRS
¶
Awalan: {}
(Daftar kosong)
List of directories searched for fixture files,
in addition to the fixtures
directory of each application, in search order.
Catat bahwa jalur-jalur ini harus menggunakan garis miring didepan gaya-Unix, bahkan pada Windows.
Lihat Provide data with fixtures dan Fixture loading.
FORCE_SCRIPT_NAME
¶
Awalan: None
If not None
, this will be used as the value of the SCRIPT_NAME
environment variable in any HTTP request. This setting can be used to override
the server-provided value of SCRIPT_NAME
, which may be a rewritten version
of the preferred value or not supplied at all. It is also used by
django.setup()
to set the URL resolver script prefix outside of the
request/response cycle (e.g. in management commands and standalone scripts) to
generate correct URLs when FORCE_SCRIPT_NAME
is provided.
FORM_RENDERER
¶
Awalan: '
django.forms.renderers.DjangoTemplates
'
The class that renders forms and form widgets. It must implement the low-level render API. Included form renderers are:
FORMS_URLFIELD_ASSUME_HTTPS
¶
Ditinggalkan sejak versi 5.0.
Awal: False
Set this transitional setting to True
to opt into using "https"
as the
new default value of URLField.assume_scheme
during the Django 5.x release cycle.
FORMAT_MODULE_PATH
¶
Awalan: None
A full Python path to a Python package that contains custom format definitions
for project locales. If not None
, Django will check for a formats.py
file, under the directory named as the current locale, and will use the
formats defined in this file.
The name of the directory containing the format definitions is expected to be
named using locale name notation, for example de
, pt_BR
,
en_US
, etc.
For example, if FORMAT_MODULE_PATH
is set to mysite.formats
,
and current language is en
(English), Django will expect a directory tree
like:
mysite/
formats/
__init__.py
en/
__init__.py
formats.py
Anda dapat juga mensetel pengaturan ini pada daftar jalur Python, sebagai contoh:
FORMAT_MODULE_PATH = [
"mysite.formats",
"some_app.formats",
]
When Django searches for a certain format, it will go through all given Python paths until it finds a module that actually defines the given format. This means that formats defined in packages farther up in the list will take precedence over the same formats in packages farther down.
Bentuk tersedia adalah:
IGNORABLE_404_URLS
¶
Awalan: {}
(Daftar kosong)
List of compiled regular expression objects describing URLs that should be
ignored when reporting HTTP 404 errors via email (see
Bagaimana mengelola pelaporan kesalahan). Regular expressions are matched against
request's full paths
(including
query string, if any). Use this if your site does not provide a commonly
requested file such as favicon.ico
or robots.txt
.
Ini hanya digunakan jika BrokenLinkEmailsMiddleware
diadakan (lihat Middleware).
INSTALLED_APPS
¶
Awalan: {}
(Daftar kosong)
A list of strings designating all applications that are enabled in this Django installation. Each string should be a dotted Python path to:
sebuah kelas konfigurasi aplikasi (disukai), atau
paket mengandung sebuah aplikasi.
Learn more about application configurations.
Gunakan registrar aplikasi untuk introspeksi
Kode anda jangan pernah mengakses INSTALLED_APPS
langsung. Gunakan django.apps.apps
sebagai gantinya.
Nama dan label aplikasi harus unik dalam INSTALLED_APPS
Application names
— the dotted Python
path to the application package — must be unique. There is no way to
include the same application twice, short of duplicating its code under
another name.
Application labels
— by default the
final part of the name — must be unique too. For example, you can't
include both django.contrib.auth
and myproject.auth
. However, you
can relabel an application with a custom configuration that defines a
different label
.
Aturan-aturan berlaku meskipun apakah INSTALLED_APPS
mengacu kelas-kelas konfigurasi aplikasi acuan atau paket-paket aplikasi
When several applications provide different versions of the same resource
(template, static file, management command, translation), the application
listed first in INSTALLED_APPS
has precedence.
INTERNAL_IPS
¶
Awalan: {}
(Daftar kosong)
Daftar dari alamat IP, sebagai string, yaitu:
Mengijinkan
debug()
pengolah konteks untuk menambah beberapa variabel pada konteks cetakan.Dapat menggunakan admindocs bookmarklets bahkan jika tidak masuk sebagai pengguna staf.
Ditandai sebagai "internal" (berlawanan dengan "EXTERNAL") dalam surel
AdminEmailHandler
.
LANGUAGE_CODE
¶
Awalan: 'en-us'
Strign mewakili kode bahasa untuk pemasangan ini. Ini harus berupa language ID format. Sebagai contoh, U.S. English adalah "en-us"
. Lihat juga list of language identifiers dan Internasionalisasi dan lokalisasi.
It serves three purposes:
Jika middleware lokal tidak digunakan, itu memutuskan terjemahan mana dilayani ke semua pengguna.
If the locale middleware is active, it provides a fallback language in case the user's preferred language can't be determined or is not supported by the website. It also provides the fallback translation when a translation for a given literal doesn't exist for the user's preferred language.
If localization is explicitly disabled via the
unlocalize
filter or the{% localize off %}
tag, it provides fallback localization formats which will be applied instead. See controlling localization in templates for details.
Lihat Bagaimana Django menemukan pilihan bahasa untuk rincian lebih.
LANGUAGES
¶
Default: A list of all available languages. This list is continually growing and including a copy here would inevitably become rapidly out of date. You can see the current list of translated languages by looking in django/conf/global_settings.py.
The list is a list of 2-tuples in the format
(language code, language name
) -- for example,
('ja', 'Japanese')
.
This specifies which languages are available for language selection. See
Internasionalisasi dan lokalisasi.
Generally, the default value should suffice. Only set this setting if you want to restrict language selection to a subset of the Django-provided languages.
Jika anda menentukan sebuah penyesuaian pengaturan LANGUAGES
, anda dapat menandai nama-nama bahasa sebagari string terjemahan menggunakan fungsi gettext_lazy()
.
Ini adalah contoh sebuah berkas pengaturan:
from django.utils.translation import gettext_lazy as _
LANGUAGES = [
("de", _("German")),
("en", _("English")),
]
LANGUAGES_BIDI
¶
Default: A list of all language codes that are written right-to-left. You can see the current list of these languages by looking in django/conf/global_settings.py.
Daftar mengandung language codes untuk bahasa yang ditulis dari kiri-ke-kanan.
Generally, the default value should suffice. Only set this setting if you want
to restrict language selection to a subset of the Django-provided languages.
If you define a custom LANGUAGES
setting, the list of bidirectional
languages may contain language codes which are not enabled on a given site.
LOCALE_PATHS
¶
Awalan: {}
(Daftar kosong)
Sebuah daftar direktori dimana Django mencari berkas terjemahan. Lihat Bagaimana Django menemukan terjemahan.
Contoh:
LOCALE_PATHS = [
"/home/www/project/common_files/locale",
"/var/local/translations/locale",
]
Django akan mencari dalam setiap jalur ini untuk direktori <locale_code>/LC_MESSAGES
mengandung berkas terjemahan sebenarnya.
LOGGING
¶
Awalan Sebuah dictionary konfigurasi pencatatan
A data structure containing configuration information. When not-empty, the
contents of this data structure will be passed as the argument to the
configuration method described in LOGGING_CONFIG
.
Among other things, the default logging configuration passes HTTP 500 server
errors to an email log handler when DEBUG
is False
. See also
Mengkonfigurasi catatan.
Anda dapat melihat konfigurasi pencatatan awalan dengan mencari dalam django/utils/log.py.
LOGGING_CONFIG
¶
Awalan: 'logging.config.dictConfig'
A path to a callable that will be used to configure logging in the Django project. Points at an instance of Python's dictConfig configuration method by default.
Jika anda tidak mensetel LOGGING_CONFIG
menjadi None
, pengolahan konfigurasi pencatatan akan dilewatkan.
MANAGERS
¶
Awalan: {}
(Daftar kosong)
A list in the same format as ADMINS
that specifies who should get
broken link notifications when
BrokenLinkEmailsMiddleware
is enabled.
MEDIA_ROOT
¶
Awalan: ''
(String kosong)
Jalur sistem berkas mutlak pada direktori yang akan menahan user-uploaded files.
Contoh: "/var/www/example.com/media/"
Lihat juga MEDIA_URL
.
Peringatan
MEDIA_ROOT
dan STATIC_ROOT
harus mempunyai nilai berbeda. Sebelum STATIC_ROOT
diperkenalkan, itu adalah umum untuk bergantung atau mundur pada MEDIA_ROOT
untuk juga melayani berkas-berkas tetap; bagaimanapun, ini dapat memiliki dapak keamanan serius, ada sebuah pemeriksaan pengesahan untuk mencegah itu.
MEDIA_URL
¶
Awalan: ''
(String kosong)
URL yang menangani media dilayani dari MEDIA_ROOT
, digunakan untuk managing stored files 1. Itu harus berakhir dalam sebuah garis miring jika menyetel ke nilai bukan-kosong. Anda akan butuh configure these files to be served 2 dalam kedua lingkungan pengembangan dan produksi.
Jika anda ingin menggunakan {{ MEDIA_URL }}
dalam cetakan-cetakan anda, tambah 'django.template.context_processors.media'
dalam pilihan 'context_processors'
dari TEMPLATES
.
Example: "https://media.example.com/"
Peringatan
Ada resiko keamanan jika anda menerima isi terunggah dari pengguna tidak dipercaya! Lihat topik panduan keamanan pada User-uploaded content untuk rincian pengurangan.
Peringatan
MEDIA_URL
dan STATIC_URL
harus mempunyai nilai berbeda. Lihat MEDIA_ROOT
untuk lebih rinci.
Catatan
If MEDIA_URL
is a relative path, then it will be prefixed by the
server-provided value of SCRIPT_NAME
(or /
if not set). This makes
it easier to serve a Django application in a subpath without adding an
extra configuration to the settings.
MIDDLEWARE
¶
Awalan: None
daftar dari middleware untuk digunakan. Lihat Middleware.
MIGRATION_MODULES
¶
Awalan: {}
(Kamus kosong)
A dictionary specifying the package where migration modules can be found on a
per-app basis. The default value of this setting is an empty dictionary, but
the default package name for migration modules is migrations
.
Contoh:
{"blog": "blog.db_migrations"}
In this case, migrations pertaining to the blog
app will be contained in
the blog.db_migrations
package.
Jika anda menyediakan argumen app_label
, makemigrations
akan otomatis membuat paket jika itu belum ada.
When you supply None
as a value for an app, Django will consider the app as
an app without migrations regardless of an existing migrations
submodule.
This can be used, for example, in a test settings file to skip migrations while
testing (tables will still be created for the apps' models). To disable
migrations for all apps during tests, you can set the
MIGRATE
to False
instead. If
MIGRATION_MODULES
is used in your general project settings, remember to use
the migrate --run-syncdb
option if you want to create tables for the
app.
MONTH_DAY_FORMAT
¶
Awalan: 'F j'
The default formatting to use for date fields on Django admin change-list pages -- and, possibly, by other parts of the system -- in cases when only the month and day are displayed.
For example, when a Django admin change-list page is being filtered by a date drilldown, the header for a given day displays the day and month. Different locales have different formats. For example, U.S. English would say "January 1," whereas Spanish might say "1 Enero."
Note that the corresponding locale-dictated format has higher precedence and will be applied instead.
Lihat allowed date format strings
. Lihat juga DATE_FORMAT
, DATETIME_FORMAT
, TIME_FORMAT
dan YEAR_MONTH_FORMAT
.
NUMBER_GROUPING
¶
Awal: 0
Sejumlah angka dikelompokkan bersama-sama pada bagian integer dari sebuah angka.
Common use is to display a thousand separator. If this setting is 0
, then
no grouping will be applied to the number. If this setting is greater than
0
, then THOUSAND_SEPARATOR
will be used as the separator between
those groups.
Some locales use non-uniform digit grouping, e.g. 10,00,00,000
in
en_IN
. For this case, you can provide a sequence with the number of digit
group sizes to be applied. The first number defines the size of the group
preceding the decimal delimiter, and each number that follows defines the size
of preceding groups. If the sequence is terminated with -1
, no further
grouping is performed. If the sequence terminates with a 0
, the last group
size is used for the remainder of the number.
Contoh tuple untuk en_IN
:
NUMBER_GROUPING = (3, 2, 0)
Note that the locale-dictated format has higher precedence and will be applied instead.
Lihat juga DECIMAL_SEPARATOR
, THOUSAND_SEPARATOR
dan USE_THOUSAND_SEPARATOR
.
PREPEND_WWW
¶
Awal: False
Apakah untuk menambahkan subranah "www." ke URL yang tidak memilikinya. Ini hanya digunakan jika CommonMiddleware
terpasang (lihat Middleware). Lihat juga APPEND_SLASH
.
ROOT_URLCONF
¶
Awalan: Tidak ditentukan
A string representing the full Python import path to your root URLconf, for
example "mydjangoapps.urls"
. Can be overridden on a per-request basis by
setting the attribute urlconf
on the incoming HttpRequest
object. See Bagaimana Django mengolah permintaan for details.
SECRET_KEY
¶
Awalan: ''
(String kosong)
A secret key for a particular Django installation. This is used to provide cryptographic signing, and should be set to a unique, unpredictable value.
django-admin startproject
otomatis menambah SECRET_KEY
dibangkitkan-acak ke setiap proyek baru.
Uses of the key shouldn't assume that it's text or bytes. Every use should go
through force_str()
or
force_bytes()
to convert it to the desired type.
Django akan menolak dimulai jika SECRET_KEY
tidak disetel.
Peringatan
Jaga nilai ini rahasia.
Running Django with a known SECRET_KEY
defeats many of Django's
security protections, and can lead to privilege escalation and remote code
execution vulnerabilities.
Kunci rahasia digunakan untuk:
All sessions if you are using any other session backend than
django.contrib.sessions.backends.cache
, or are using the defaultget_session_auth_hash()
.All messages if you are using
CookieStorage
orFallbackStorage
.Semua token
PasswordResetView
.Penggunaan apapun dari cryptographic signing, meskipun kunci berbeda disediakan.
When a secret key is no longer set as SECRET_KEY
or contained within
SECRET_KEY_FALLBACKS
all of the above will be invalidated. When
rotating your secret key, you should move the old key to
SECRET_KEY_FALLBACKS
temporarily. Secret keys are not used for
passwords of users and key rotation will not affect them.
Catatan
Berkas settings.py
awalan dibuat oleh django-admin startproject
membuat SECRET_KEY
unik untuk kenyamanan.
SECRET_KEY_FALLBACKS
¶
Default: []
A list of fallback secret keys for a particular Django installation. These are
used to allow rotation of the SECRET_KEY
.
In order to rotate your secret keys, set a new SECRET_KEY
and move the
previous value to the beginning of SECRET_KEY_FALLBACKS
. Then remove the
old values from the end of the SECRET_KEY_FALLBACKS
when you are ready to
expire the sessions, password reset tokens, and so on, that make use of them.
Catatan
Signing operations are computationally expensive. Having multiple old key
values in SECRET_KEY_FALLBACKS
adds additional overhead to all checks
that don't match an earlier key.
As such, fallback values should be removed after an appropriate period, allowing for key rotation.
Uses of the secret key values shouldn't assume that they are text or bytes.
Every use should go through force_str()
or
force_bytes()
to convert it to the desired type.
SECURE_CONTENT_TYPE_NOSNIFF
¶
Awal: True
Jika True
, SecurityMiddleware
mesetel kepala X-Content-Type-Options: nosniff pada semua tanggapan yang belum memiliki itu.
SECURE_CROSS_ORIGIN_OPENER_POLICY
¶
Awalan: 'same-origin'
Unless set to None
, the
SecurityMiddleware
sets the
Cross-Origin Opener Policy header on all responses that do not already
have it to the value provided.
SECURE_HSTS_INCLUDE_SUBDOMAINS
¶
Awal: False
If True
, the SecurityMiddleware
adds
the includeSubDomains
directive to the HTTP Strict Transport Security
header. It has no effect unless SECURE_HSTS_SECONDS
is set to a
non-zero value.
Peringatan
Setting this incorrectly can irreversibly (for the value of
SECURE_HSTS_SECONDS
) break your site. Read the
HTTP Strict Transport Security documentation first.
SECURE_HSTS_PRELOAD
¶
Awal: False
If True
, the SecurityMiddleware
adds
the preload
directive to the HTTP Strict Transport Security
header. It has no effect unless SECURE_HSTS_SECONDS
is set to a
non-zero value.
SECURE_HSTS_SECONDS
¶
Awal: 0
If set to a non-zero integer value, the
SecurityMiddleware
sets the
HTTP Strict Transport Security header on all responses that do not
already have it.
Peringatan
Setting this incorrectly can irreversibly (for some time) break your site. Read the HTTP Strict Transport Security documentation first.
SECURE_PROXY_SSL_HEADER
¶
Awalan: None
A tuple representing an HTTP header/value combination that signifies a request
is secure. This controls the behavior of the request object's is_secure()
method.
By default, is_secure()
determines if a request is secure by confirming
that a requested URL uses https://
. This method is important for Django's
CSRF protection, and it may be used by your own code or third-party apps.
If your Django app is behind a proxy, though, the proxy may be "swallowing"
whether the original request uses HTTPS or not. If there is a non-HTTPS
connection between the proxy and Django then is_secure()
would always
return False
-- even for requests that were made via HTTPS by the end user.
In contrast, if there is an HTTPS connection between the proxy and Django then
is_secure()
would always return True
-- even for requests that were
made originally via HTTP.
In this situation, configure your proxy to set a custom HTTP header that tells
Django whether the request came in via HTTPS, and set
SECURE_PROXY_SSL_HEADER
so that Django knows what header to look for.
Setel sebuah tuple dengan dua unsur -- nama dari kepala untuk mencari dan nilai diwajibkan. Sebagai contoh:
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
This tells Django to trust the X-Forwarded-Proto
header that comes from our
proxy and that the request is guaranteed to be secure (i.e., it originally came
in via HTTPS) when:
the header value is
'https'
, orits initial, leftmost value is
'https'
in the case of a comma-separated list of protocols (e.g.'https,http,http'
).
You should only set this setting if you control your proxy or have some other guarantee that it sets/strips this header appropriately.
Note that the header needs to be in the format as used by request.META
--
all caps and likely starting with HTTP_
. (Remember, Django automatically
adds 'HTTP_'
to the start of x-header names before making the header
available in request.META
.)
Peringatan
Merubah pengaturan ini dapat membahayakan keamanan situs anda. Pastikan anda sepenuhnya memahami pengaturan anda sebelum merubah itu.
Pastikan SEMUA dari berikut adalah benar sebelum mengatur ini (menganggap nilai-nilai dari contoh diatas):
Aplikasi Django anda dibelakang proxy.
Your proxy strips the
X-Forwarded-Proto
header from all incoming requests, even when it contains a comma-separated list of protocols. In other words, if end users include that header in their requests, the proxy will discard it.Your proxy sets the
X-Forwarded-Proto
header and sends it to Django, but only for requests that originally come in via HTTPS.
If any of those are not true, you should keep this setting set to None
and find another way of determining HTTPS, perhaps via custom middleware.
SECURE_REDIRECT_EXEMPT
¶
Awalan: {}
(Daftar kosong)
If a URL path matches a regular expression in this list, the request will not be
redirected to HTTPS. The
SecurityMiddleware
strips leading slashes
from URL paths, so patterns shouldn't include them, e.g.
SECURE_REDIRECT_EXEMPT = [r'^no-ssl/$', …]
. If
SECURE_SSL_REDIRECT
is False
, this setting has no effect.
SECURE_REFERRER_POLICY
¶
Awalan: 'same-origin'
If configured, the SecurityMiddleware
sets
the Referrer Policy header on all responses that do not already have it
to the value provided.
SECURE_SSL_HOST
¶
Awalan: None
If a string (e.g. secure.example.com
), all SSL redirects will be directed
to this host rather than the originally-requested host
(e.g. www.example.com
). If SECURE_SSL_REDIRECT
is False
, this
setting has no effect.
SECURE_SSL_REDIRECT
¶
Awal: False
If True
, the SecurityMiddleware
redirects all non-HTTPS requests to HTTPS (except for
those URLs matching a regular expression listed in
SECURE_REDIRECT_EXEMPT
).
Catatan
If turning this to True
causes infinite redirects, it probably means
your site is running behind a proxy and can't tell which requests are secure
and which are not. Your proxy likely sets a header to indicate secure
requests; you can correct the problem by finding out what that header is and
configuring the SECURE_PROXY_SSL_HEADER
setting accordingly.
SERIALIZATION_MODULES
¶
Awalan: Tidak ditentukan
A dictionary of modules containing serializer definitions (provided as strings), keyed by a string identifier for that serialization type. For example, to define a YAML serializer, use:
SERIALIZATION_MODULES = {"yaml": "path.to.yaml_serializer"}
SERVER_EMAIL
¶
Awal: 'root@localhost'
The email address that error messages come from, such as those sent to
ADMINS
and MANAGERS
. This address is used in the
From:
header and can take any format valid in the chosen email sending
protocol.
Mengapa surel saya dikirim dari alamat berbeda?
This address is used only for error messages. It is not the address that
regular email messages sent with send_mail()
come from; for that, see DEFAULT_FROM_EMAIL
.
SHORT_DATE_FORMAT
¶
Awalan: 'm/d/Y'
(misalnya 12/31/2003
)
An available formatting that can be used for displaying date fields on
templates. Note that the corresponding locale-dictated format has higher
precedence and will be applied instead. See
allowed date format strings
.
Lihat juga DATE_FORMAT
dan SHORT_DATETIME_FORMAT
.
SHORT_DATETIME_FORMAT
¶
Awalan: 'm/d/Y P'
(misalnya 12/31/2003 4 p.m.
)
An available formatting that can be used for displaying datetime fields on
templates. Note that the corresponding locale-dictated format has higher
precedence and will be applied instead. See
allowed date format strings
.
Lihat juga DATE_FORMAT
dan SHORT_DATE_FORMAT
.
SIGNING_BACKEND
¶
Awalan: 'django.core.signing.TimestampSigner'
Backend digunakan unntuk tandatangan kue dan data lain.
Lihat juga dokumentasi Penandatanganan Kriptrograpi.
SILENCED_SYSTEM_CHECKS
¶
Awalan: {}
(Daftar kosong)
Sebuah daftar penciri dari pesan-pesan dibangkitkan oleh kerangka sistem pemeriksaan (yaitu ["models.W001"]`) yang anda harapkan secara tetap mengakui dan mengabaikan. Pemeriksaan diam-diam tidak akan dikeluarkan ke konsol.
Lihat juga dokumentasi Kerangka pemeriksaan sistem.
STORAGES
¶
Awal:
{
"default": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
},
"staticfiles": {
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
},
}
A dictionary containing the settings for all storages to be used with Django. It is a nested dictionary whose contents map a storage alias to a dictionary containing the options for an individual storage.
Storages can have any alias you choose. However, there are two aliases with special significance:
default
for managing files.'
django.core.files.storage.FileSystemStorage
'
is the default storage engine.staticfiles
for managing static files.'
django.contrib.staticfiles.storage.StaticFilesStorage
'
is the default storage engine.
The following is an example settings.py
snippet defining a custom file
storage called example
:
STORAGES = {
# ...
"example": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
"OPTIONS": {
"location": "/example",
"base_url": "/example/",
},
},
}
OPTIONS
are passed to the BACKEND
on initialization in **kwargs
.
A ready-to-use instance of the storage backends can be retrieved from
django.core.files.storage.storages
. Use a key corresponding to the
backend definition in STORAGES
.
Is my value merged with the default value?
Defining this setting overrides the default value and is not merged with it.
TEMPLATES
¶
Awalan: {}
(Daftar kosong)
A list containing the settings for all template engines to be used with Django. Each item of the list is a dictionary containing the options for an individual engine.
Here's a setup that tells the Django template engine to load templates from the
templates
subdirectory inside each installed application:
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"APP_DIRS": True,
},
]
Pilihan berikut tersedia untuk semua backend.
BACKEND
¶
Awalan: Tidak ditentukan
Backend cetakan untuk digunakan. Backend cetakan siap-pakai adalah:
'django.template.backends.django.DjangoTemplates'
'django.template.backends.jinja2.Jinja2'
You can use a template backend that doesn't ship with Django by setting
BACKEND
to a fully-qualified path (i.e. 'mypackage.whatever.Backend'
).
NAME
¶
Awalan: lihat dibawah
The alias for this particular template engine. It's an identifier that allows selecting an engine for rendering. Aliases must be unique across all configured template engines.
It defaults to the name of the module defining the engine class, i.e. the
next to last piece of BACKEND
, when it isn't
provided. For example if the backend is 'mypackage.whatever.Backend'
then
its default name is 'whatever'
.
DIRS
¶
Awalan: {}
(Daftar kosong)
Direktori-direktori dimana mesih harus dicari untuk berkas-berkas sumber cetakan, dalam urutan pencarian.
APP_DIRS
¶
Awal: False
Apakah mesin harus terlihat untuk berkas sumber cetakan didalam aplikasi terpasang.
Catatan
Berkas settings.py
awalan dibuat oleh django-admin startproject
mensetel 'APP_DIRS': True
.
OPTIONS
¶
Awalan: {}
(dict kosong)
Extra parameters to pass to the template backend. Available parameters vary
depending on the template backend. See
DjangoTemplates
and
Jinja2
for the options of the
built-in backends.
TEST_RUNNER
¶
Awalan: 'django.test.runner.DiscoverRunner'
Nama dari kelas untuk digunakan untuk memulai antrian percobaan. Lihat Menggunakan kerangka percobaan berbeda.
TEST_NON_SERIALIZED_APPS
¶
Awalan: {}
(Daftar kosong)
In order to restore the database state between tests for
TransactionTestCase
s and database backends without transactions, Django
will serialize the contents of all apps
when it starts the test run so it can then reload from that copy before running
tests that need it.
This slows down the startup time of the test runner; if you have apps that
you know don't need this feature, you can add their full names in here (e.g.
'django.contrib.contenttypes'
) to exclude them from this serialization
process.
THOUSAND_SEPARATOR
¶
Awalan: ','
(Koma)
Default thousand separator used when formatting numbers. This setting is
used only when USE_THOUSAND_SEPARATOR
is True
and
NUMBER_GROUPING
is greater than 0
.
Note that the locale-dictated format has higher precedence and will be applied instead.
Lihat juga NUMBER_GROUPING
, DECIMAL_SEPARATOR
dan USE_THOUSAND_SEPARATOR
.
TIME_FORMAT
¶
Awalan: 'P'
(misalnya 4 p.m.
)
The default formatting to use for displaying time fields in any part of the
system. Note that the locale-dictated format has higher precedence and will be
applied instead. See allowed date format strings
.
Lihat juga DATE_FORMAT
dan DATETIME_FORMAT
.
TIME_INPUT_FORMATS
¶
Awal:
[
"%H:%M:%S", # '14:30:59'
"%H:%M:%S.%f", # '14:30:59.000200'
"%H:%M", # '14:30'
]
A list of formats that will be accepted when inputting data on a time field.
Formats will be tried in order, using the first valid one. Note that these
format strings use Python's datetime module syntax, not the format strings from the date
template filter.
The locale-dictated format has higher precedence and will be applied instead.
Lihat juga DATE_INPUT_FORMATS
dan DATETIME_INPUT_FORMATS
.
TIME_ZONE
¶
Awalan: 'America/Chicago'
Sebuah string mewakili zona waktu untuk pemasangan ini. Lihat list of time zones.
Catatan
Since Django was first released with the TIME_ZONE
set to
'America/Chicago'
, the global setting (used if nothing is defined in
your project's settings.py
) remains 'America/Chicago'
for backwards
compatibility. New project templates default to 'UTC'
.
Note that this isn't necessarily the time zone of the server. For example, one server may serve multiple Django-powered sites, each with a separate time zone setting.
When USE_TZ
is False
, this is the time zone in which Django
will store all datetimes. When USE_TZ
is True
, this is the
default time zone that Django will use to display datetimes in templates and
to interpret datetimes entered in forms.
On Unix environments (where time.tzset()
is implemented), Django sets the
os.environ['TZ']
variable to the time zone you specify in the
TIME_ZONE
setting. Thus, all your views and models will
automatically operate in this time zone. However, Django won't set the TZ
environment variable if you're using the manual configuration option as
described in manually configuring settings. If Django doesn't set the TZ
environment variable, it's up to you to ensure your processes are running in
the correct environment.
Catatan
Django cannot reliably use alternate time zones in a Windows environment.
If you're running Django on Windows, TIME_ZONE
must be set to
match the system time zone.
USE_I18N
¶
Awal: True
A boolean that specifies whether Django's translation system should be enabled.
This provides a way to turn it off, for performance. If this is set to
False
, Django will make some optimizations so as not to load the
translation machinery.
See also LANGUAGE_CODE
and USE_TZ
.
Catatan
Berkas awalan settings.py
dibuat oleh django-admin startproject
termasuk USE_I18N = True
untuk kenyamanan.
USE_THOUSAND_SEPARATOR
¶
Awal: False
A boolean that specifies whether to display numbers using a thousand separator.
When set to True
, Django will format numbers using the
NUMBER_GROUPING
and THOUSAND_SEPARATOR
settings. The
latter two settings may also be dictated by the locale, which takes precedence.
Lihat juga DECIMAL_SEPARATOR
, NUMBER_GROUPING
dan THOUSAND_SEPARATOR
.
USE_TZ
¶
Awal: True
A boolean that specifies if datetimes will be timezone-aware by default or not.
If this is set to True
, Django will use timezone-aware datetimes internally.
When USE_TZ
is False, Django will use naive datetimes in local time, except
when parsing ISO 8601 formatted strings, where timezone information will always
be retained if present.
See also TIME_ZONE
and USE_I18N
.
In older versions, the default value is False
.
USE_X_FORWARDED_HOST
¶
Awal: False
A boolean that specifies whether to use the X-Forwarded-Host
header in
preference to the Host
header. This should only be enabled if a proxy
which sets this header is in use.
This setting takes priority over USE_X_FORWARDED_PORT
. Per
RFC 7239 Section 5.3, the X-Forwarded-Host
header can include the port
number, in which case you shouldn't use USE_X_FORWARDED_PORT
.
USE_X_FORWARDED_PORT
¶
Awal: False
A boolean that specifies whether to use the X-Forwarded-Port
header in
preference to the SERVER_PORT
META
variable. This should only be
enabled if a proxy which sets this header is in use.
USE_X_FORWARDED_HOST
mengambil prioritas terhadap pengaturan ini.
WSGI_APPLICATION
¶
Awalan: None
The full Python path of the WSGI application object that Django's built-in
servers (e.g. runserver
) will use. The django-admin
startproject
management command will create a standard
wsgi.py
file with an application
callable in it, and point this setting
to that application
.
If not set, the return value of django.core.wsgi.get_wsgi_application()
will be used. In this case, the behavior of runserver
will be
identical to previous Django versions.
YEAR_MONTH_FORMAT
¶
Awalan: 'F Y'
The default formatting to use for date fields on Django admin change-list pages -- and, possibly, by other parts of the system -- in cases when only the year and month are displayed.
For example, when a Django admin change-list page is being filtered by a date drilldown, the header for a given month displays the month and the year. Different locales have different formats. For example, U.S. English would say "January 2006," whereas another locale might say "2006/January."
Note that the corresponding locale-dictated format has higher precedence and will be applied instead.
Lihat allowed date format strings
. Lihat juga DATE_FORMAT
, DATETIME_FORMAT
, TIME_FORMAT
dan MONTH_DAY_FORMAT
.
X_FRAME_OPTIONS
¶
Awalan: 'DENY'
Nilai awalan untuk kepala X-Frame-Options digunakan oleh XFrameOptionsMiddleware
. Lihat dokumentasi clickjacking protection.
Sahih¶
Pengaturan untuk django.contrib.auth
.
AUTHENTICATION_BACKENDS
¶
Awalan: ['django.contrib.auth.backends.ModelBackend']
A list of authentication backend classes (as strings) to use when attempting to authenticate a user. See the authentication backends documentation for details.
AUTH_USER_MODEL
¶
Awalan: 'auth.User'
Model digunakan untuk mewakili User. Lihat Mengganti model User penyesuaian.
Peringatan
You cannot change the AUTH_USER_MODEL setting during the lifetime of a project (i.e. once you have made and migrated models that depend on it) without serious effort. It is intended to be set at the project start, and the model it refers to must be available in the first migration of the app that it lives in. See Mengganti model User penyesuaian for more details.
LOGIN_REDIRECT_URL
¶
Awalan: '/accounts/profile/'
The URL or named URL pattern where requests are
redirected after login when the LoginView
doesn't get a next
GET parameter.
LOGIN_URL
¶
Awalan: '/accounts/login/'
The URL or named URL pattern where requests are
redirected for login when using the
login_required()
decorator,
LoginRequiredMixin
,
AccessMixin
, or when
LoginRequiredMiddleware
is installed.
LOGOUT_REDIRECT_URL
¶
Awalan: None
The URL or named URL pattern where requests are
redirected after logout if LogoutView
doesn't have a next_page
attribute.
Jika None
, pengalihan tidak akan dilakukan dan tampilan keluar akan dibangun.
PASSWORD_RESET_TIMEOUT
¶
Awalan: 259200
(3 hari, dalam detik)
Jumlah detik dari tautan setel kembali sandi yang sah.
Digunakan oleh PasswordResetConfirmView
.
Catatan
Reducing the value of this timeout doesn't make any difference to the ability of an attacker to brute-force a password reset token. Tokens are designed to be safe from brute-forcing without any timeout.
This timeout exists to protect against some unlikely attack scenarios, such as someone gaining access to email archives that may contain old, unused password reset tokens.
PASSWORD_HASHERS
¶
Lihat Bagaimana Django menyimpan sandi.
Awal:
[
"django.contrib.auth.hashers.PBKDF2PasswordHasher",
"django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher",
"django.contrib.auth.hashers.Argon2PasswordHasher",
"django.contrib.auth.hashers.BCryptSHA256PasswordHasher",
"django.contrib.auth.hashers.ScryptPasswordHasher",
]
AUTH_PASSWORD_VALIDATORS
¶
Awalan: {}
(Daftar kosong)
The list of validators that are used to check the strength of user's passwords. See Pengesahan sandi for more details. By default, no validation is performed and all passwords are accepted.
Pesan¶
Pengaturan django.contrib.messages
.
MESSAGE_LEVEL
¶
Awalan: messages.INFO
Setel tingkatan pesan minimal yang akan direkam oleh kerangka kerja pesan. Lihat message levels untuk rincian lebih.
Avoiding circular imports
Jika anda menimpa MESSAGE_LEVEL
dalam berkas pengaturan anda dan bergantung pada ketetapan siap-pakai apapun, anda harus mengimpor modul ketetapan langsung untuk menghindari kemungkinan impor berputar, misalnya.:
from django.contrib.messages import constants as message_constants
MESSAGE_LEVEL = message_constants.DEBUG
Jika diinginkan, anda mungkin menentukan nilai numerik untuk ketetapan langsung menurut nilai dalam constants table diatas.
MESSAGE_STORAGE
¶
Awalan: 'django.contrib.messages.storage.fallback.FallbackStorage'
Mengendalikan dimana Django menyimpan data pesan. Nilai sah adalah:
'django.contrib.messages.storage.fallback.FallbackStorage'
'django.contrib.messages.storage.session.SessionStorage'
'django.contrib.messages.storage.cookie.CookieStorage'
Lihat message storage backends untuk lebih rinci.
Backend yang menggunakan kue -- CookieStorage
dan FallbackStorage
-- menggunakan nilai dari SESSION_COOKIE_DOMAIN
, SESSION_COOKIE_SECURE
dan SESSION_COOKIE_HTTPONLY
ketika menyetel kue mereka.
Sesi¶
Pengaturan untuk django.contrib.sessions
.
SESSION_CACHE_ALIAS
¶
Awalan: 'default'
Jika anda sedang menggunakan cache-based session storage, ini memilih cache untuk digunakan.
SESSION_ENGINE
¶
Awalan: 'django.contrib.sessions.backends.db'
Mengendalikan dimana Django menyimpan data sesi. Mesin yang disertakan adalah:
'django.contrib.sessions.backends.db'
'django.contrib.sessions.backends.file'
'django.contrib.sessions.backends.cache'
'django.contrib.sessions.backends.cached_db'
'django.contrib.sessions.backends.signed_cookies'
Lihat Konfigurasi mesin sesi untuk rincian lebih.
SESSION_EXPIRE_AT_BROWSER_CLOSE
¶
Awal: False
Whether to expire the session when the user closes their browser. See Browser-length sessions vs. persistent sessions.
SESSION_FILE_PATH
¶
Awalan: None
If you're using file-based session storage, this sets the directory in
which Django will store session data. When the default value (None
) is
used, Django will use the standard temporary directory for the system.
SESSION_SAVE_EVERY_REQUEST
¶
Awal: False
Whether to save the session data on every request. If this is False
(default), then the session data will only be saved if it has been modified --
that is, if any of its dictionary values have been assigned or deleted. Empty
sessions won't be created, even if this setting is active.
SESSION_SERIALIZER
¶
Awalan: 'django.contrib.sessions.serializers.JSONSerializer'
Full import path of a serializer class to use for serializing session data. Included serializer is:
'django.contrib.sessions.serializers.JSONSerializer'
See Serialisasi sesi for details.
Situs¶
Pengaturan untuk django.contrib.sites
.
SITE_ID
¶
Awalan: Tidak ditentukan
The ID, as an integer, of the current site in the django_site
database
table. This is used so that application data can hook into specific sites
and a single database can manage content for multiple sites.
Bidang Tetap¶
Pengaturan untuk django.contrib.staticfiles
.
STATIC_ROOT
¶
Awalan: None
Jalur mutlak ke direktori dimana collectstatic
akan mengumpulkan berkas-berkas tetap untuk pengembangan.
Contoh: "/var/www/example.com/static/"
If the staticfiles contrib app is enabled
(as in the default project template), the collectstatic
management
command will collect static files into this directory. See the how-to on
managing static files for more details about
usage.
Peringatan
This should be an initially empty destination directory for collecting
your static files from their permanent locations into one directory for
ease of deployment; it is not a place to store your static files
permanently. You should do that in directories that will be found by
staticfiles’s
finders
, which by default, are
'static/'
app sub-directories and any directories you include in
STATICFILES_DIRS
).
STATIC_URL
¶
Awalan: None
URL digunakan ketika mengacu ke berkas-berkas tetap bertempat dalam STATIC_ROOT
.
Example: "static/"
or "https://static.example.com/"
Jika bukan None
, ini akan digunakan sebagai jalur dasar untuk asset definitions (kelas Media
) dan staticfiles app.
Itu harus berakhir dalam sebuah garis miring jika disetel ke nilai bukan-kosong.
Anda mungkin butuh untuk configure these files to be served in development dan akan sangat perlu melakukan itu in production.
Catatan
If STATIC_URL
is a relative path, then it will be prefixed by
the server-provided value of SCRIPT_NAME
(or /
if not set). This
makes it easier to serve a Django application in a subpath without adding
an extra configuration to the settings.
STATICFILES_DIRS
¶
Awalan: {}
(Daftar kosong)
This setting defines the additional locations the staticfiles app will traverse
if the FileSystemFinder
finder is enabled, e.g. if you use the
collectstatic
or findstatic
management command or use the
static file serving view.
Ini harus berupa kumpulan dari daftar string yang mengandung jalur penuh ke berkas-berkas tambahan anda misalnya:
STATICFILES_DIRS = [
"/home/special.polls.com/polls/static",
"/home/polls.com/polls/static",
"/opt/webfiles/common",
]
Catat bahwa jalur-jalur ini harus menggunakan garis miring depan gaya-Unix, bahkan pada Windows (misalnya "C:/Users/user/mysite/extra_static_content"
).
Awalan (pilihan)¶
Dalam kasus anda ingin mengacu pada berkas-berkas dalam satu dari tempat-tempat dengan namespace tambahan, anda dapat pilihan menyediakan awalan sebagai tuple-tuple (prefix, path)
, misalnya:
STATICFILES_DIRS = [
# ...
("downloads", "/opt/webfiles/stats"),
]
For example, assuming you have STATIC_URL
set to 'static/'
, the
collectstatic
management command would collect the "stats" files
in a 'downloads'
subdirectory of STATIC_ROOT
.
Ini akan mengizinkan anda mengacu ke berkasl lokal '/opt/webfiles/stats/polls_20101022.tar.gz'
dengan '/static/downloads/polls_20101022.tar.gz'
dalam cetakan anda, misalnya:
<a href="{% static 'downloads/polls_20101022.tar.gz' %}">
STATICFILES_FINDERS
¶
Awal:
[
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
]
Daftar dari penemu backend yang mengetahui bagaimana menemukan berkas-berkas statis dalam beragam tempat.
The default will find files stored in the STATICFILES_DIRS
setting
(using django.contrib.staticfiles.finders.FileSystemFinder
) and in a
static
subdirectory of each app (using
django.contrib.staticfiles.finders.AppDirectoriesFinder
). If multiple
files with the same name are present, the first file that is found will be
used.
One finder is disabled by default:
django.contrib.staticfiles.finders.DefaultStorageFinder
. If added to
your STATICFILES_FINDERS
setting, it will look for static files in
the default file storage as defined by the default
key in the
STORAGES
setting.
Catatan
When using the AppDirectoriesFinder
finder, make sure your apps
can be found by staticfiles by adding the app to the
INSTALLED_APPS
setting of your site.
Penemu berkas statis saat ini dianggap antarmuka pribadi, dan antarmuka ini dengan demikian tidak terdokumentasi.
Core Settings Topical Index¶
Tembolok¶
Basisdata¶
Mencari kesalahan¶
Surel¶
Pelaporan kesalahan¶
Unggah berkas¶
Formulir¶
Globalisasi (i18n
/l10n
)¶
Internationalization (i18n
)¶
Localization (l10n
)¶
HTTP¶
Keamanan
Pencatatan¶
Model¶
Keamanan¶
Serialisasi¶
Templat¶
Pengujian¶
Basisdata:
TEST