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.weblog': lambda o: "/blogs/%s/" % o.slug,
    'news.story': lambda o: "/stories/%s/%s/" % (o.pub_year, o.slug),
}

Note that the model name used in this setting should be all lower-case, 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.MemcachedCache'
  • 'django.core.cache.backends.memcached.PyLibMCCache'

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)

Tempat dari penyimpanan sementara untuk digunakan. Ini mungkin direktori untuk penyimpanan sementara sistem berkas, sebuah rumah dan port untuk peladen memcache, atau cukup sebuah nama penciri untuk memori penyimpanan sementara lokal. misalnya:

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

Jumlah detik sebelum masukan penyimpanan sementara dianggap stabil. Jika nilai dari pengaturan ini adalah None, masukan penyimpanan sementara tidak akan kadaluarsa.

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

Awal: 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.

Lihat Kerangka kerja penyimpanan Django.

CACHE_MIDDLEWARE_SECONDS

Awalan: 600

Jumlah detik untuk menyimpan sementara halaman untuk cache middleware.

Lihat Kerangka kerja penyimpanan Django.

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.

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 hosts which are trusted origins for unsafe requests (e.g. POST). For a secure unsafe request, Django's CSRF protection requires that the request have a Referer header that matches the origin present in the Host header. This prevents, for example, a POST request from subdomain.example.com from succeeding against api.example.com. If you need cross-origin unsafe requests over HTTPS, continuing the example, add "subdomain.example.com" to this list. The setting also supports subdomains, so you could add ".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',
    }
}

ketika berhubungan ke backend basisdata lain, seperti MySQL, Oracle, atau PostgreSQL, parameter hubungan tambahan akan dibutuhkan. Lihat pengaturan ENGINE dibawah pada bagaimana menentukan jenis-jenis basisdata lain. Contoh ini untuk 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

Umur hidup dari hubungan basisdata, dalam detik. Gunakan``0`` untuk menutup hubungan basisdata pada akhir dari setiap permintaan — perilaku riwayat Django — dan None untuk hubungan tetap tidak terbatas.

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

Sebuah string mewakili zona waktu untuk datetime disimpan dalam basisdata ini (menganggap bahwa itu tidak mendukung zona waktu) atau None. Pilihan paling dalam ini dari pengaturan DATABASES menerima nilai-nilai sama seperti pengaturan umum TIME_ZONE.

Ini mengizinkan berinteraksi dengan basisdata pihak-ketiga yang menyimpan datetime dalam waktu lokal daripada UTC. Untuk menghidnari masalah-masalah seputar perubahan DST, anda tidak harus mensetel pilihan ini untuk basisdata dikelola oleh Django.

Ketika USE_TZ adalah True dan basisdata tidak mendukung zona waktu (misalnya SQLite, MySQL, Oracle), Django membaca dan menulis datetimes dalam waktu lokal menurut pada pilihan ini jika itu disetel dan dalam UTC jika tidak.

Ketika USE_TZ adalah True dan basisdata mendukung zona waktu (misalnya PostgreSQL), itu adalah sebuah kesalahan untuk menyetel pilihan ini.

Ketika USE_TZ adalah False, itu adalah sebuah kesalahan untuk menyetel pilihan ini.

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

Default: ['default'], for all databases other than default, which has no dependencies.

The creation-order dependencies of the database. See the documentation on controlling the creation order of test databases for details.

MIRROR

Awalan: None

Nama lain dari basisdata bahwa basisdata ini harus bercermin selama percobaan.

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.

SERIALIZE

Boolean value to control whether or not the default test runner serializes the database into an in-memory JSON string before running tests (used to restore the database state between tests if you don't have transactions). You can set this to False to speed up creation time if you don't have any test classes with serialized_rollback=True.

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.

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
New in Django 2.0:

Awalan: '50M'

Ini adalah sebuah pengaturan khusus-Oracle.

Ukuran inisial dari DATAFILE.

DATAFILE_TMP_SIZE
New in Django 2.0:

Awalan: '50M'

Ini adalah sebuah pengaturan khusus-Oracle.

Ukuran inisial dari DATAFILE_TMP.

DATAFILE_EXTSIZE
New in Django 2.0:

Awalan: '25M'

Ini adalah sebuah pengaturan khusus-Oracle.

Jumlah dimana DATAFILE diperpanjang ketika ruang lebih dubutuhkan.

DATAFILE_TMP_EXTSIZE
New in Django 2.0:

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.

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 if USE_L10N is set to True, then 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', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06'
    '%b %d %Y', '%b %d, %Y',            # 'Oct 25 2006', 'Oct 25, 2006'
    '%d %b %Y', '%d %b, %Y',            # '25 Oct 2006', '25 Oct, 2006'
    '%B %d %Y', '%B %d, %Y',            # 'October 25 2006', 'October 25, 2006'
    '%d %B %Y', '%d %B, %Y',            # '25 October 2006', '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.

When USE_L10N is True, 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 if USE_L10N is set to True, then 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'
    '%Y-%m-%d',              # '2006-10-25'
    '%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',              # '10/25/2006'
    '%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'
    '%m/%d/%y',              # '10/25/06'
]

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.

When USE_L10N is True, 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 upwards.

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 if USE_L10N is set to True, then the locale-dictated format has higher precedence and will be applied instead.

Lihat juga NUMBER_GROUPING, THOUSAND_SEPARATOR dan USE_THOUSAND_SEPARATOR.

DEFAULT_CHARSET

Awalan: 'utf-8'

Default charset to use for all HttpResponse objects, if a MIME type isn't manually specified. Used with DEFAULT_CONTENT_TYPE to construct the Content-Type header.

DEFAULT_CONTENT_TYPE

Awalan: 'text/html'

Jenis isi awalan pada penggunaan untuk semua obyek HttpResponse, jika jenis MIME tidak secara manual ditentukan. Digunakan dengan DEFAULT_CHARSET untuk membangun kepala Content-Type.

Ditinggalkan sejak versi 2.0: Pengaturan ini diusangkan karena itu tidak berinteraksi baik dengan apliaksi pihak-ketiga dan usang sejak HTML5 kebanyakan digantikan XHTML.

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_FILE_STORAGE

Awalan: 'django.core.files.storage.FileSystemStorage'

Kelas penyimpanan berkas awalan untuk digunakan untuk tindakan terkait-berkas apapun yang tidak menentukan sistem penyimpanan tertentu. Lihat Mengelola berkas.

DEFAULT_FROM_EMAIL

Awalan: 'webmaster@localhost'

Default email address to use for various automated correspondence from the site manager(s). This doesn't include error messages sent to ADMINS and MANAGERS; for that, see SERVER_EMAIL.

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'

Backend digunakan untuk mengirim surel. Untuk daftar dari backend tersedia lihat Mengirim surel.

EMAIL_FILE_PATH

Awalan: Tidak ditentukan

Direktori digunakan oleh backend surel file untuk menyimpan berkas keluaran.

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.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_CHARSET

Awalan: 'utf-8'

Penyandian karakter digunakan untuk membaca sandi berkas apapun dibaca dari cakram. ini termasuk berkas-berkas cetakan dan berkas-berkas data SQL inisial.

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: None

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().

Jika ini tidak diberika atau None, anda akan mendapatkan kebiasan ketergantungan sistem-operasi. Pada kebanyakan serambi, berkas sementara akan memiliki suasana dari 0o600, dan berkas-berkas disimpan dari penyimpanan akan disimpan menggunakan umask standar sistem.

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

Selalu awalan suasana dengan 0.

If you're not familiar with file modes, please note that the leading 0 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 Menyediakan data dengan perlengkapan 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 SCRIPT_NAME is not /.

FORM_RENDERER

Awalan: 'django.forms.renderers.DjangoTemplates'

Kelas yang membangun widget formulir. Itu harus menerapkan the low-level render API.

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.

Sebagai contoh, jika FORMAT_MODULE_PATH disetel ke mysite.formats, dan bahasa saat ini adalah en (Inggris), Django akan mengaharpkan pohon direktori seperti:

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 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.

USE_I18N harus aktif untuk pengaturan ini untuk memberikan pengaruh.

Itu melayani dua tujuan:

  • 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.

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 (or view the online source).

The list is a list of two-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.

If you define a custom LANGUAGES setting, you can mark the language names as translation strings using the gettext_lazy() function.

Ini adalah contoh sebuah berkas pengaturan:

from django.utils.translation import gettext_lazy as _

LANGUAGES = [
    ('de', _('German')),
    ('en', _('English')),
]

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. 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.

You can see the default logging configuration by looking in django/utils/log.py (or view the online source).

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.

If you set LOGGING_CONFIG to None, the logging configuration process will be skipped.

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 and STATIC_ROOT must have different values. Before STATIC_ROOT was introduced, it was common to rely or fallback on MEDIA_ROOT to also serve static files; however, since this can have serious security implications, there is a validation check to prevent it.

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.

If you want to use {{ MEDIA_URL }} in your templates, add 'django.template.context_processors.media' in the 'context_processors' option of TEMPLATES.

Contoh: "http://media.example.com/"

Peringatan

There are security risks if you are accepting uploaded content from untrusted users! See the security guide's topic on User-uploaded content for mitigation details.

Peringatan

MEDIA_URL dan STATIC_URL harus mempunyai nilai berbeda. Lihat MEDIA_ROOT untuk lebih rinci.

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). If this 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."

Catat bahwa jika USE_L10N disetel menjadi True, kemudian bentuk sesuai lokal-yang-ditentukan memiliki hak lebih tinggi dan akan diberlakukan.

Lihat allowed date format strings. Lihat juga DATE_FORMAT, DATETIME_FORMAT, TIME_FORMAT dan YEAR_MONTH_FORMAT.

NUMBER_GROUPING

Awal: 0

Number of digits grouped together on the integer part of a number.

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 if USE_L10N is set to True, then 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.

Penggunaan kunci tidak harus dianggap bahwa itu adalah teks atay byte. Setiap penggunaan harus melalui force_text() atau force_bytes() untuk merubah itu ke jenis yang diinginkan.

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:

Jika anda memutar kunci rahasia anda, semua diatas akan tidak sah. Kunci-kunci rahasia tidak digunakan untuk sandi dari pengguna dan perputaran kunci tidak akan mempengaruhi mereka.

Catatan

Berkas settings.py awalan dibuat oleh django-admin startproject membuat SECRET_KEY unik untuk kenyamanan.

SECURE_BROWSER_XSS_FILTER

Awal: False

Jika True, SecurityMiddleware mensetel kepala X-XSS-Protection: 1; mode=block pada semua tanggapan yang belum memiliki itu.

SECURE_CONTENT_TYPE_NOSNIFF

Awal: False

Jika True, SecurityMiddleware mesetel kepala X-Content-Type-Options: nosniff pada semua tanggapan yang belum memiliki itu.

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 a 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" the fact that a request is HTTPS, using a non-HTTPS connection between the proxy and Django. In this case, is_secure() would always return False -- even for requests that were made via HTTPS by the end user.

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.

Set a tuple with two elements -- the name of the header to look for and the required value. For example:

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 any time its value is 'https', then the request is guaranteed to be secure (i.e., it originally came in via HTTPS).

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

Modifying this setting can compromise your site's security. Ensure you fully understand your setup before changing it.

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. 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. If SECURE_SSL_REDIRECT is False, this setting has no effect.

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.

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 if USE_L10N is set to True, then the corresponding locale-dictated format has higher precedence and will be applied. 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 if USE_L10N is set to True, then the corresponding locale-dictated format has higher precedence and will be applied. 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.

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 simple 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)

Directories where the engine should look for template source files, in search order.

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 TransactionTestCases 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 if USE_L10N is set to True, then 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 if USE_L10N is set to True, then 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.

When USE_L10N is True, 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 an easy 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.

Lihat juga LANGUAGE_CODE, USE_L10N dan USE_TZ.

Catatan

Berkas awalan settings.py dibuat oleh django-admin startproject termasuk USE_I18N = True untuk kenyamanan.

USE_L10N

Awal: False

A boolean that specifies if localized formatting of data will be enabled by default or not. If this is set to True, e.g. Django will display numbers and dates using the format of the current locale.

Lihat juga LANGUAGE_CODE, USE_I18N dan USE_TZ.

Catatan

The default settings.py file created by django-admin startproject includes USE_L10N = True for convenience.

USE_THOUSAND_SEPARATOR

Awal: False

A boolean that specifies whether to display numbers using a thousand separator. When USE_L10N is set to True and if this is also set to True, Django will use the values of THOUSAND_SEPARATOR and NUMBER_GROUPING to format numbers unless the locale already has an existing thousands separator. If there is a thousands separator in the locale format, it will have higher precedence and will be applied instead.

Lihat juga DECIMAL_SEPARATOR, NUMBER_GROUPING dan THOUSAND_SEPARATOR.

USE_TZ

Awal: False

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. Otherwise, Django will use naive datetimes in local time.

Lihat juga TIME_ZONE, USE_I18N dan USE_L10N.

Catatan

The default settings.py file created by django-admin startproject includes USE_TZ = True for convenience.

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.

Pengaturan ini mengambil keutamaan terhadap USE_X_FORWARDED_PORT. Per RFC 7239#page-7, kepala X-Forwarded-Host dapat menyertakan nomor port, dalam hal ini anda jangan menggunakan 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 simple 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."

Catat bahwa jika USE_L10N disetel menjadi True, kemudian bentuk sesuai lokal-yang-ditentukan memiliki hak lebih tinggi dan akan diberlakukan.

Lihat allowed date format strings. Lihat juga DATE_FORMAT, DATETIME_FORMAT, TIME_FORMAT dan MONTH_DAY_FORMAT.

X_FRAME_OPTIONS

Awalan: 'SAMEORIGIN'

The default value for the X-Frame-Options header used by XFrameOptionsMiddleware. See the clickjacking protection documentation.

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/'

URL dimana permintaan dialihkan setelah masuk ketika tampilan contrib.auth.login tidak mendapatkan parameter next.

Ini digunakan oleh penghias login_required(), sebagai contoh.

This setting also accepts named URL patterns which can be used to reduce configuration duplication since you don't have to define the URL in two places (settings and URLconf).

LOGIN_URL

Awalan: '/accounts/login/'

The URL where requests are redirected for login, especially when using the login_required() decorator.

This setting also accepts named URL patterns which can be used to reduce configuration duplication since you don't have to define the URL in two places (settings and URLconf).

LOGOUT_REDIRECT_URL

Awalan: None

The URL where requests are redirected after a user logs out using LogoutView (if the view doesn't get a next_page argument).

Jika None, pengalihan tidak akan dilakukan dan tampilan keluar akan dibangun.

This setting also accepts named URL patterns which can be used to reduce configuration duplication since you don't have to define the URL in two places (settings and URLconf).

PASSWORD_RESET_TIMEOUT_DAYS

Awalan: 3

The minimum number of days a password reset link is valid for. Depending on when the link is generated, it will be valid for up to a day longer.

Digunakan oleh PasswordResetConfirmView.

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',
]

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.

Penting

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.

MESSAGE_TAGS

Awal:

{
    messages.DEBUG: 'debug',
    messages.INFO: 'info',
    messages.SUCCESS: 'success',
    messages.WARNING: 'warning',
    messages.ERROR: 'error',
}

This sets the mapping of message level to message tag, which is typically rendered as a CSS class in HTML. If you specify a value, it will extend the default. This means you only have to specify those values which you need to override. See Menampilkan pesan above for more details.

Penting

Jika anda menimpa MESSAGE_TAGS dalam berkas pengaturan anda dan bergantung pada ketetapan siap-pakai apapun, anda harus mengimpor modul constants langsung untuk menghindari kemungkinan impor berputar, misalnya.:

from django.contrib.messages import constants as message_constants
MESSAGE_TAGS = {message_constants.INFO: ''}

Jika diinginkan, anda mungkin menentukan nilai numerik untuk ketetapan langsung menurut nilai dalam constants table diatas.

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 serializers are:

  • 'django.contrib.sessions.serializers.PickleSerializer'
  • 'django.contrib.sessions.serializers.JSONSerializer'

See Serialisasi sesi for details, including a warning regarding possible remote code execution when using PickleSerializer.

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.

Contoh: "/static/" atau "http://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.

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_STORAGE

Awalan: 'django.contrib.staticfiles.storage.StaticFilesStorage'

Mesin penyimpanan berkas digunakan ketika mengumpulkan berkas-berkas statis dengan perintah pengelolaan collectstatic.

Sebauh contoh siap-pakai dari backend penyimpanan ditentukan dalam pengaturan ini dapat ditemukan pada django.contrib.staticfiles.storage.staticfiles_storage.

Sebagai sebuah contoh, lihat Melayani berkas statis dari layanan cloud atau CDN.

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_FILE_STORAGE setting.

Catatan

When using the AppDirectoriesFinder finder, make sure your apps can be found by staticfiles. Simply add 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

Formulir

Templat

Back to Top