settings.txt 110 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667
  1. ========
  2. Settings
  3. ========
  4. .. contents::
  5. :local:
  6. :depth: 1
  7. .. warning::
  8. Be careful when you override settings, especially when the default value
  9. is a non-empty list or dictionary, such as :setting:`STATICFILES_FINDERS`.
  10. Make sure you keep the components required by the features of Django you
  11. wish to use.
  12. Core Settings
  13. =============
  14. Here's a list of settings available in Django core and their default values.
  15. Settings provided by contrib apps are listed below, followed by a topical index
  16. of the core settings. For introductory material, see the :doc:`settings topic
  17. guide </topics/settings>`.
  18. .. setting:: ABSOLUTE_URL_OVERRIDES
  19. ``ABSOLUTE_URL_OVERRIDES``
  20. --------------------------
  21. Default: ``{}`` (Empty dictionary)
  22. A dictionary mapping ``"app_label.model_name"`` strings to functions that take
  23. a model object and return its URL. This is a way of inserting or overriding
  24. ``get_absolute_url()`` methods on a per-installation basis. Example::
  25. ABSOLUTE_URL_OVERRIDES = {
  26. 'blogs.weblog': lambda o: "/blogs/%s/" % o.slug,
  27. 'news.story': lambda o: "/stories/%s/%s/" % (o.pub_year, o.slug),
  28. }
  29. The model name used in this setting should be all lowercase, regardless of the
  30. case of the actual model class name.
  31. .. setting:: ADMINS
  32. ``ADMINS``
  33. ----------
  34. Default: ``[]`` (Empty list)
  35. A list of all the people who get code error notifications. When
  36. :setting:`DEBUG=False <DEBUG>` and :class:`~django.utils.log.AdminEmailHandler`
  37. is configured in :setting:`LOGGING` (done by default), Django emails these
  38. people the details of exceptions raised in the request/response cycle.
  39. Each item in the list should be a tuple of (Full name, email address). Example::
  40. [('John', 'john@example.com'), ('Mary', 'mary@example.com')]
  41. .. setting:: ALLOWED_HOSTS
  42. ``ALLOWED_HOSTS``
  43. -----------------
  44. Default: ``[]`` (Empty list)
  45. A list of strings representing the host/domain names that this Django site can
  46. serve. This is a security measure to prevent :ref:`HTTP Host header attacks
  47. <host-headers-virtual-hosting>`, which are possible even under many
  48. seemingly-safe web server configurations.
  49. Values in this list can be fully qualified names (e.g. ``'www.example.com'``),
  50. in which case they will be matched against the request's ``Host`` header
  51. exactly (case-insensitive, not including port). A value beginning with a period
  52. can be used as a subdomain wildcard: ``'.example.com'`` will match
  53. ``example.com``, ``www.example.com``, and any other subdomain of
  54. ``example.com``. A value of ``'*'`` will match anything; in this case you are
  55. responsible to provide your own validation of the ``Host`` header (perhaps in a
  56. middleware; if so this middleware must be listed first in
  57. :setting:`MIDDLEWARE`).
  58. Django also allows the `fully qualified domain name (FQDN)`_ of any entries.
  59. Some browsers include a trailing dot in the ``Host`` header which Django
  60. strips when performing host validation.
  61. .. _`fully qualified domain name (FQDN)`: https://en.wikipedia.org/wiki/Fully_qualified_domain_name
  62. If the ``Host`` header (or ``X-Forwarded-Host`` if
  63. :setting:`USE_X_FORWARDED_HOST` is enabled) does not match any value in this
  64. list, the :meth:`django.http.HttpRequest.get_host()` method will raise
  65. :exc:`~django.core.exceptions.SuspiciousOperation`.
  66. When :setting:`DEBUG` is ``True`` and ``ALLOWED_HOSTS`` is empty, the host
  67. is validated against ``['.localhost', '127.0.0.1', '[::1]']``.
  68. ``ALLOWED_HOSTS`` is also :ref:`checked when running tests
  69. <topics-testing-advanced-multiple-hosts>`.
  70. This validation only applies via :meth:`~django.http.HttpRequest.get_host()`;
  71. if your code accesses the ``Host`` header directly from ``request.META`` you
  72. are bypassing this security protection.
  73. .. versionchanged:: 3.1
  74. If ``ALLOWED_HOSTS`` is empty and ``DEBUG=True``, subdomains of localhost
  75. were allowed.
  76. .. setting:: APPEND_SLASH
  77. ``APPEND_SLASH``
  78. ----------------
  79. Default: ``True``
  80. When set to ``True``, if the request URL does not match any of the patterns
  81. in the URLconf and it doesn't end in a slash, an HTTP redirect is issued to the
  82. same URL with a slash appended. Note that the redirect may cause any data
  83. submitted in a POST request to be lost.
  84. The :setting:`APPEND_SLASH` setting is only used if
  85. :class:`~django.middleware.common.CommonMiddleware` is installed
  86. (see :doc:`/topics/http/middleware`). See also :setting:`PREPEND_WWW`.
  87. .. setting:: CACHES
  88. ``CACHES``
  89. ----------
  90. Default::
  91. {
  92. 'default': {
  93. 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
  94. }
  95. }
  96. A dictionary containing the settings for all caches to be used with
  97. Django. It is a nested dictionary whose contents maps cache aliases
  98. to a dictionary containing the options for an individual cache.
  99. The :setting:`CACHES` setting must configure a ``default`` cache;
  100. any number of additional caches may also be specified. If you
  101. are using a cache backend other than the local memory cache, or
  102. you need to define multiple caches, other options will be required.
  103. The following cache options are available.
  104. .. setting:: CACHES-BACKEND
  105. ``BACKEND``
  106. ~~~~~~~~~~~
  107. Default: ``''`` (Empty string)
  108. The cache backend to use. The built-in cache backends are:
  109. * ``'django.core.cache.backends.db.DatabaseCache'``
  110. * ``'django.core.cache.backends.dummy.DummyCache'``
  111. * ``'django.core.cache.backends.filebased.FileBasedCache'``
  112. * ``'django.core.cache.backends.locmem.LocMemCache'``
  113. * ``'django.core.cache.backends.memcached.MemcachedCache'``
  114. * ``'django.core.cache.backends.memcached.PyLibMCCache'``
  115. You can use a cache backend that doesn't ship with Django by setting
  116. :setting:`BACKEND <CACHES-BACKEND>` to a fully-qualified path of a cache
  117. backend class (i.e. ``mypackage.backends.whatever.WhateverCache``).
  118. .. setting:: CACHES-KEY_FUNCTION
  119. ``KEY_FUNCTION``
  120. ~~~~~~~~~~~~~~~~
  121. A string containing a dotted path to a function (or any callable) that defines how to
  122. compose a prefix, version and key into a final cache key. The default
  123. implementation is equivalent to the function::
  124. def make_key(key, key_prefix, version):
  125. return ':'.join([key_prefix, str(version), key])
  126. You may use any key function you want, as long as it has the same
  127. argument signature.
  128. See the :ref:`cache documentation <cache_key_transformation>` for more
  129. information.
  130. .. setting:: CACHES-KEY_PREFIX
  131. ``KEY_PREFIX``
  132. ~~~~~~~~~~~~~~
  133. Default: ``''`` (Empty string)
  134. A string that will be automatically included (prepended by default) to
  135. all cache keys used by the Django server.
  136. See the :ref:`cache documentation <cache_key_prefixing>` for more information.
  137. .. setting:: CACHES-LOCATION
  138. ``LOCATION``
  139. ~~~~~~~~~~~~
  140. Default: ``''`` (Empty string)
  141. The location of the cache to use. This might be the directory for a
  142. file system cache, a host and port for a memcache server, or an identifying
  143. name for a local memory cache. e.g.::
  144. CACHES = {
  145. 'default': {
  146. 'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
  147. 'LOCATION': '/var/tmp/django_cache',
  148. }
  149. }
  150. .. setting:: CACHES-OPTIONS
  151. ``OPTIONS``
  152. ~~~~~~~~~~~
  153. Default: ``None``
  154. Extra parameters to pass to the cache backend. Available parameters
  155. vary depending on your cache backend.
  156. Some information on available parameters can be found in the
  157. :ref:`cache arguments <cache_arguments>` documentation. For more information,
  158. consult your backend module's own documentation.
  159. .. setting:: CACHES-TIMEOUT
  160. ``TIMEOUT``
  161. ~~~~~~~~~~~
  162. Default: ``300``
  163. The number of seconds before a cache entry is considered stale. If the value of
  164. this settings is ``None``, cache entries will not expire.
  165. .. setting:: CACHES-VERSION
  166. ``VERSION``
  167. ~~~~~~~~~~~
  168. Default: ``1``
  169. The default version number for cache keys generated by the Django server.
  170. See the :ref:`cache documentation <cache_versioning>` for more information.
  171. .. setting:: CACHE_MIDDLEWARE_ALIAS
  172. ``CACHE_MIDDLEWARE_ALIAS``
  173. --------------------------
  174. Default: ``default``
  175. The cache connection to use for the :ref:`cache middleware
  176. <the-per-site-cache>`.
  177. .. setting:: CACHE_MIDDLEWARE_KEY_PREFIX
  178. ``CACHE_MIDDLEWARE_KEY_PREFIX``
  179. -------------------------------
  180. Default: ``''`` (Empty string)
  181. A string which will be prefixed to the cache keys generated by the :ref:`cache
  182. middleware <the-per-site-cache>`. This prefix is combined with the
  183. :setting:`KEY_PREFIX <CACHES-KEY_PREFIX>` setting; it does not replace it.
  184. See :doc:`/topics/cache`.
  185. .. setting:: CACHE_MIDDLEWARE_SECONDS
  186. ``CACHE_MIDDLEWARE_SECONDS``
  187. ----------------------------
  188. Default: ``600``
  189. The default number of seconds to cache a page for the :ref:`cache middleware
  190. <the-per-site-cache>`.
  191. See :doc:`/topics/cache`.
  192. .. _settings-csrf:
  193. .. setting:: CSRF_COOKIE_AGE
  194. ``CSRF_COOKIE_AGE``
  195. -------------------
  196. Default: ``31449600`` (approximately 1 year, in seconds)
  197. The age of CSRF cookies, in seconds.
  198. The reason for setting a long-lived expiration time is to avoid problems in
  199. the case of a user closing a browser or bookmarking a page and then loading
  200. that page from a browser cache. Without persistent cookies, the form submission
  201. would fail in this case.
  202. Some browsers (specifically Internet Explorer) can disallow the use of
  203. persistent cookies or can have the indexes to the cookie jar corrupted on disk,
  204. thereby causing CSRF protection checks to (sometimes intermittently) fail.
  205. Change this setting to ``None`` to use session-based CSRF cookies, which
  206. keep the cookies in-memory instead of on persistent storage.
  207. .. setting:: CSRF_COOKIE_DOMAIN
  208. ``CSRF_COOKIE_DOMAIN``
  209. ----------------------
  210. Default: ``None``
  211. The domain to be used when setting the CSRF cookie. This can be useful for
  212. easily allowing cross-subdomain requests to be excluded from the normal cross
  213. site request forgery protection. It should be set to a string such as
  214. ``"example.com"`` to allow a POST request from a form on one subdomain to be
  215. accepted by a view served from another subdomain.
  216. Please note that the presence of this setting does not imply that Django's CSRF
  217. protection is safe from cross-subdomain attacks by default - please see the
  218. :ref:`CSRF limitations <csrf-limitations>` section.
  219. .. setting:: CSRF_COOKIE_HTTPONLY
  220. ``CSRF_COOKIE_HTTPONLY``
  221. ------------------------
  222. Default: ``False``
  223. Whether to use ``HttpOnly`` flag on the CSRF cookie. If this is set to
  224. ``True``, client-side JavaScript will not be able to access the CSRF cookie.
  225. Designating the CSRF cookie as ``HttpOnly`` doesn't offer any practical
  226. protection because CSRF is only to protect against cross-domain attacks. If an
  227. attacker can read the cookie via JavaScript, they're already on the same domain
  228. as far as the browser knows, so they can do anything they like anyway. (XSS is
  229. a much bigger hole than CSRF.)
  230. Although the setting offers little practical benefit, it's sometimes required
  231. by security auditors.
  232. If you enable this and need to send the value of the CSRF token with an AJAX
  233. request, your JavaScript must pull the value :ref:`from a hidden CSRF token
  234. form input <acquiring-csrf-token-from-html>` instead of :ref:`from the cookie
  235. <acquiring-csrf-token-from-cookie>`.
  236. See :setting:`SESSION_COOKIE_HTTPONLY` for details on ``HttpOnly``.
  237. .. setting:: CSRF_COOKIE_NAME
  238. ``CSRF_COOKIE_NAME``
  239. --------------------
  240. Default: ``'csrftoken'``
  241. The name of the cookie to use for the CSRF authentication token. This can be
  242. whatever you want (as long as it's different from the other cookie names in
  243. your application). See :doc:`/ref/csrf`.
  244. .. setting:: CSRF_COOKIE_PATH
  245. ``CSRF_COOKIE_PATH``
  246. --------------------
  247. Default: ``'/'``
  248. The path set on the CSRF cookie. This should either match the URL path of your
  249. Django installation or be a parent of that path.
  250. This is useful if you have multiple Django instances running under the same
  251. hostname. They can use different cookie paths, and each instance will only see
  252. its own CSRF cookie.
  253. .. setting:: CSRF_COOKIE_SAMESITE
  254. ``CSRF_COOKIE_SAMESITE``
  255. ------------------------
  256. Default: ``'Lax'``
  257. The value of the `SameSite`_ flag on the CSRF cookie. This flag prevents the
  258. cookie from being sent in cross-site requests.
  259. See :setting:`SESSION_COOKIE_SAMESITE` for details about ``SameSite``.
  260. .. versionchanged:: 3.1
  261. Setting ``CSRF_COOKIE_SAMESITE = 'None'`` was allowed.
  262. .. setting:: CSRF_COOKIE_SECURE
  263. ``CSRF_COOKIE_SECURE``
  264. ----------------------
  265. Default: ``False``
  266. Whether to use a secure cookie for the CSRF cookie. If this is set to ``True``,
  267. the cookie will be marked as "secure", which means browsers may ensure that the
  268. cookie is only sent with an HTTPS connection.
  269. .. setting:: CSRF_USE_SESSIONS
  270. ``CSRF_USE_SESSIONS``
  271. ---------------------
  272. Default: ``False``
  273. Whether to store the CSRF token in the user's session instead of in a cookie.
  274. It requires the use of :mod:`django.contrib.sessions`.
  275. Storing the CSRF token in a cookie (Django's default) is safe, but storing it
  276. in the session is common practice in other web frameworks and therefore
  277. sometimes demanded by security auditors.
  278. Since the :ref:`default error views <error-views>` require the CSRF token,
  279. :class:`~django.contrib.sessions.middleware.SessionMiddleware` must appear in
  280. :setting:`MIDDLEWARE` before any middleware that may raise an exception to
  281. trigger an error view (such as :exc:`~django.core.exceptions.PermissionDenied`)
  282. if you're using ``CSRF_USE_SESSIONS``. See :ref:`middleware-ordering`.
  283. .. setting:: CSRF_FAILURE_VIEW
  284. ``CSRF_FAILURE_VIEW``
  285. ---------------------
  286. Default: ``'django.views.csrf.csrf_failure'``
  287. A dotted path to the view function to be used when an incoming request is
  288. rejected by the :doc:`CSRF protection </ref/csrf>`. The function should have
  289. this signature::
  290. def csrf_failure(request, reason=""):
  291. ...
  292. where ``reason`` is a short message (intended for developers or logging, not
  293. for end users) indicating the reason the request was rejected. It should return
  294. an :class:`~django.http.HttpResponseForbidden`.
  295. ``django.views.csrf.csrf_failure()`` accepts an additional ``template_name``
  296. parameter that defaults to ``'403_csrf.html'``. If a template with that name
  297. exists, it will be used to render the page.
  298. .. setting:: CSRF_HEADER_NAME
  299. ``CSRF_HEADER_NAME``
  300. --------------------
  301. Default: ``'HTTP_X_CSRFTOKEN'``
  302. The name of the request header used for CSRF authentication.
  303. As with other HTTP headers in ``request.META``, the header name received from
  304. the server is normalized by converting all characters to uppercase, replacing
  305. any hyphens with underscores, and adding an ``'HTTP_'`` prefix to the name.
  306. For example, if your client sends a ``'X-XSRF-TOKEN'`` header, the setting
  307. should be ``'HTTP_X_XSRF_TOKEN'``.
  308. .. setting:: CSRF_TRUSTED_ORIGINS
  309. ``CSRF_TRUSTED_ORIGINS``
  310. ------------------------
  311. Default: ``[]`` (Empty list)
  312. A list of hosts which are trusted origins for unsafe requests (e.g. ``POST``).
  313. For a :meth:`secure <django.http.HttpRequest.is_secure>` unsafe
  314. request, Django's CSRF protection requires that the request have a ``Referer``
  315. header that matches the origin present in the ``Host`` header. This prevents,
  316. for example, a ``POST`` request from ``subdomain.example.com`` from succeeding
  317. against ``api.example.com``. If you need cross-origin unsafe requests over
  318. HTTPS, continuing the example, add ``"subdomain.example.com"`` to this list.
  319. The setting also supports subdomains, so you could add ``".example.com"``, for
  320. example, to allow access from all subdomains of ``example.com``.
  321. .. setting:: DATABASES
  322. ``DATABASES``
  323. -------------
  324. Default: ``{}`` (Empty dictionary)
  325. A dictionary containing the settings for all databases to be used with
  326. Django. It is a nested dictionary whose contents map a database alias
  327. to a dictionary containing the options for an individual database.
  328. The :setting:`DATABASES` setting must configure a ``default`` database;
  329. any number of additional databases may also be specified.
  330. The simplest possible settings file is for a single-database setup using
  331. SQLite. This can be configured using the following::
  332. DATABASES = {
  333. 'default': {
  334. 'ENGINE': 'django.db.backends.sqlite3',
  335. 'NAME': 'mydatabase',
  336. }
  337. }
  338. When connecting to other database backends, such as MariaDB, MySQL, Oracle, or
  339. PostgreSQL, additional connection parameters will be required. See
  340. the :setting:`ENGINE <DATABASE-ENGINE>` setting below on how to specify
  341. other database types. This example is for PostgreSQL::
  342. DATABASES = {
  343. 'default': {
  344. 'ENGINE': 'django.db.backends.postgresql',
  345. 'NAME': 'mydatabase',
  346. 'USER': 'mydatabaseuser',
  347. 'PASSWORD': 'mypassword',
  348. 'HOST': '127.0.0.1',
  349. 'PORT': '5432',
  350. }
  351. }
  352. The following inner options that may be required for more complex
  353. configurations are available:
  354. .. setting:: DATABASE-ATOMIC_REQUESTS
  355. ``ATOMIC_REQUESTS``
  356. ~~~~~~~~~~~~~~~~~~~
  357. Default: ``False``
  358. Set this to ``True`` to wrap each view in a transaction on this database. See
  359. :ref:`tying-transactions-to-http-requests`.
  360. .. setting:: DATABASE-AUTOCOMMIT
  361. ``AUTOCOMMIT``
  362. ~~~~~~~~~~~~~~
  363. Default: ``True``
  364. Set this to ``False`` if you want to :ref:`disable Django's transaction
  365. management <deactivate-transaction-management>` and implement your own.
  366. .. setting:: DATABASE-ENGINE
  367. ``ENGINE``
  368. ~~~~~~~~~~
  369. Default: ``''`` (Empty string)
  370. The database backend to use. The built-in database backends are:
  371. * ``'django.db.backends.postgresql'``
  372. * ``'django.db.backends.mysql'``
  373. * ``'django.db.backends.sqlite3'``
  374. * ``'django.db.backends.oracle'``
  375. You can use a database backend that doesn't ship with Django by setting
  376. ``ENGINE`` to a fully-qualified path (i.e. ``mypackage.backends.whatever``).
  377. .. setting:: HOST
  378. ``HOST``
  379. ~~~~~~~~
  380. Default: ``''`` (Empty string)
  381. Which host to use when connecting to the database. An empty string means
  382. localhost. Not used with SQLite.
  383. If this value starts with a forward slash (``'/'``) and you're using MySQL,
  384. MySQL will connect via a Unix socket to the specified socket. For example::
  385. "HOST": '/var/run/mysql'
  386. If you're using MySQL and this value *doesn't* start with a forward slash, then
  387. this value is assumed to be the host.
  388. If you're using PostgreSQL, by default (empty :setting:`HOST`), the connection
  389. to the database is done through UNIX domain sockets ('local' lines in
  390. ``pg_hba.conf``). If your UNIX domain socket is not in the standard location,
  391. use the same value of ``unix_socket_directory`` from ``postgresql.conf``.
  392. If you want to connect through TCP sockets, set :setting:`HOST` to 'localhost'
  393. or '127.0.0.1' ('host' lines in ``pg_hba.conf``).
  394. On Windows, you should always define :setting:`HOST`, as UNIX domain sockets
  395. are not available.
  396. .. setting:: NAME
  397. ``NAME``
  398. ~~~~~~~~
  399. Default: ``''`` (Empty string)
  400. The name of the database to use. For SQLite, it's the full path to the database
  401. file. When specifying the path, always use forward slashes, even on Windows
  402. (e.g. ``C:/homes/user/mysite/sqlite3.db``).
  403. .. setting:: CONN_MAX_AGE
  404. ``CONN_MAX_AGE``
  405. ~~~~~~~~~~~~~~~~
  406. Default: ``0``
  407. The lifetime of a database connection, as an integer of seconds. Use ``0`` to
  408. close database connections at the end of each request — Django's historical
  409. behavior — and ``None`` for unlimited persistent connections.
  410. .. setting:: OPTIONS
  411. ``OPTIONS``
  412. ~~~~~~~~~~~
  413. Default: ``{}`` (Empty dictionary)
  414. Extra parameters to use when connecting to the database. Available parameters
  415. vary depending on your database backend.
  416. Some information on available parameters can be found in the
  417. :doc:`Database Backends </ref/databases>` documentation. For more information,
  418. consult your backend module's own documentation.
  419. .. setting:: PASSWORD
  420. ``PASSWORD``
  421. ~~~~~~~~~~~~
  422. Default: ``''`` (Empty string)
  423. The password to use when connecting to the database. Not used with SQLite.
  424. .. setting:: PORT
  425. ``PORT``
  426. ~~~~~~~~
  427. Default: ``''`` (Empty string)
  428. The port to use when connecting to the database. An empty string means the
  429. default port. Not used with SQLite.
  430. .. setting:: DATABASE-TIME_ZONE
  431. ``TIME_ZONE``
  432. ~~~~~~~~~~~~~
  433. Default: ``None``
  434. A string representing the time zone for this database connection or ``None``.
  435. This inner option of the :setting:`DATABASES` setting accepts the same values
  436. as the general :setting:`TIME_ZONE` setting.
  437. When :setting:`USE_TZ` is ``True`` and this option is set, reading datetimes
  438. from the database returns aware datetimes in this time zone instead of UTC.
  439. When :setting:`USE_TZ` is ``False``, it is an error to set this option.
  440. * If the database backend doesn't support time zones (e.g. SQLite, MySQL,
  441. Oracle), Django reads and writes datetimes in local time according to this
  442. option if it is set and in UTC if it isn't.
  443. Changing the connection time zone changes how datetimes are read from and
  444. written to the database.
  445. * If Django manages the database and you don't have a strong reason to do
  446. otherwise, you should leave this option unset. It's best to store datetimes
  447. in UTC because it avoids ambiguous or nonexistent datetimes during daylight
  448. saving time changes. Also, receiving datetimes in UTC keeps datetime
  449. arithmetic simple — there's no need for the ``normalize()`` method provided
  450. by pytz.
  451. * If you're connecting to a third-party database that stores datetimes in a
  452. local time rather than UTC, then you must set this option to the
  453. appropriate time zone. Likewise, if Django manages the database but
  454. third-party systems connect to the same database and expect to find
  455. datetimes in local time, then you must set this option.
  456. * If the database backend supports time zones (e.g. PostgreSQL), the
  457. ``TIME_ZONE`` option is very rarely needed. It can be changed at any time;
  458. the database takes care of converting datetimes to the desired time zone.
  459. Setting the time zone of the database connection may be useful for running
  460. raw SQL queries involving date/time functions provided by the database, such
  461. as ``date_trunc``, because their results depend on the time zone.
  462. However, this has a downside: receiving all datetimes in local time makes
  463. datetime arithmetic more tricky — you must call the ``normalize()`` method
  464. provided by pytz after each operation.
  465. Consider converting to local time explicitly with ``AT TIME ZONE`` in raw SQL
  466. queries instead of setting the ``TIME_ZONE`` option.
  467. .. versionchanged:: 3.1
  468. Using this option when the database backend supports time zones was allowed.
  469. .. setting:: DATABASE-DISABLE_SERVER_SIDE_CURSORS
  470. ``DISABLE_SERVER_SIDE_CURSORS``
  471. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  472. Default: ``False``
  473. Set this to ``True`` if you want to disable the use of server-side cursors with
  474. :meth:`.QuerySet.iterator`. :ref:`transaction-pooling-server-side-cursors`
  475. describes the use case.
  476. This is a PostgreSQL-specific setting.
  477. .. setting:: USER
  478. ``USER``
  479. ~~~~~~~~
  480. Default: ``''`` (Empty string)
  481. The username to use when connecting to the database. Not used with SQLite.
  482. .. setting:: DATABASE-TEST
  483. ``TEST``
  484. ~~~~~~~~
  485. Default: ``{}`` (Empty dictionary)
  486. A dictionary of settings for test databases; for more details about the
  487. creation and use of test databases, see :ref:`the-test-database`.
  488. Here's an example with a test database configuration::
  489. DATABASES = {
  490. 'default': {
  491. 'ENGINE': 'django.db.backends.postgresql',
  492. 'USER': 'mydatabaseuser',
  493. 'NAME': 'mydatabase',
  494. 'TEST': {
  495. 'NAME': 'mytestdatabase',
  496. },
  497. },
  498. }
  499. The following keys in the ``TEST`` dictionary are available:
  500. .. setting:: TEST_CHARSET
  501. ``CHARSET``
  502. ^^^^^^^^^^^
  503. Default: ``None``
  504. The character set encoding used to create the test database. The value of this
  505. string is passed directly through to the database, so its format is
  506. backend-specific.
  507. Supported by the PostgreSQL_ (``postgresql``) and MySQL_ (``mysql``) backends.
  508. .. _PostgreSQL: https://www.postgresql.org/docs/current/multibyte.html
  509. .. _MySQL: https://dev.mysql.com/doc/refman/en/charset-charsets.html
  510. .. setting:: TEST_COLLATION
  511. ``COLLATION``
  512. ^^^^^^^^^^^^^
  513. Default: ``None``
  514. The collation order to use when creating the test database. This value is
  515. passed directly to the backend, so its format is backend-specific.
  516. Only supported for the ``mysql`` backend (see the `MySQL manual`_ for details).
  517. .. _MySQL manual: MySQL_
  518. .. setting:: TEST_DEPENDENCIES
  519. ``DEPENDENCIES``
  520. ^^^^^^^^^^^^^^^^
  521. Default: ``['default']``, for all databases other than ``default``,
  522. which has no dependencies.
  523. The creation-order dependencies of the database. See the documentation
  524. on :ref:`controlling the creation order of test databases
  525. <topics-testing-creation-dependencies>` for details.
  526. .. setting:: TEST_MIGRATE
  527. ``MIGRATE``
  528. ^^^^^^^^^^^
  529. .. versionadded:: 3.1
  530. Default: ``True``
  531. When set to ``False``, migrations won't run when creating the test database.
  532. .. setting:: TEST_MIRROR
  533. ``MIRROR``
  534. ^^^^^^^^^^
  535. Default: ``None``
  536. The alias of the database that this database should mirror during
  537. testing.
  538. This setting exists to allow for testing of primary/replica
  539. (referred to as master/slave by some databases)
  540. configurations of multiple databases. See the documentation on
  541. :ref:`testing primary/replica configurations
  542. <topics-testing-primaryreplica>` for details.
  543. .. setting:: TEST_NAME
  544. ``NAME``
  545. ^^^^^^^^
  546. Default: ``None``
  547. The name of database to use when running the test suite.
  548. If the default value (``None``) is used with the SQLite database engine, the
  549. tests will use a memory resident database. For all other database engines the
  550. test database will use the name ``'test_' + DATABASE_NAME``.
  551. See :ref:`the-test-database`.
  552. .. setting:: TEST_SERIALIZE
  553. ``SERIALIZE``
  554. ^^^^^^^^^^^^^
  555. Boolean value to control whether or not the default test runner serializes the
  556. database into an in-memory JSON string before running tests (used to restore
  557. the database state between tests if you don't have transactions). You can set
  558. this to ``False`` to speed up creation time if you don't have any test classes
  559. with :ref:`serialized_rollback=True <test-case-serialized-rollback>`.
  560. .. setting:: TEST_TEMPLATE
  561. ``TEMPLATE``
  562. ^^^^^^^^^^^^
  563. This is a PostgreSQL-specific setting.
  564. The name of a `template`_ (e.g. ``'template0'``) from which to create the test
  565. database.
  566. .. _template: https://www.postgresql.org/docs/current/sql-createdatabase.html
  567. .. setting:: TEST_CREATE
  568. ``CREATE_DB``
  569. ^^^^^^^^^^^^^
  570. Default: ``True``
  571. This is an Oracle-specific setting.
  572. If it is set to ``False``, the test tablespaces won't be automatically created
  573. at the beginning of the tests or dropped at the end.
  574. .. setting:: TEST_USER_CREATE
  575. ``CREATE_USER``
  576. ^^^^^^^^^^^^^^^
  577. Default: ``True``
  578. This is an Oracle-specific setting.
  579. If it is set to ``False``, the test user won't be automatically created at the
  580. beginning of the tests and dropped at the end.
  581. .. setting:: TEST_USER
  582. ``USER``
  583. ^^^^^^^^
  584. Default: ``None``
  585. This is an Oracle-specific setting.
  586. The username to use when connecting to the Oracle database that will be used
  587. when running tests. If not provided, Django will use ``'test_' + USER``.
  588. .. setting:: TEST_PASSWD
  589. ``PASSWORD``
  590. ^^^^^^^^^^^^
  591. Default: ``None``
  592. This is an Oracle-specific setting.
  593. The password to use when connecting to the Oracle database that will be used
  594. when running tests. If not provided, Django will generate a random password.
  595. .. setting:: TEST_ORACLE_MANAGED_FILES
  596. ``ORACLE_MANAGED_FILES``
  597. ^^^^^^^^^^^^^^^^^^^^^^^^
  598. Default: ``False``
  599. This is an Oracle-specific setting.
  600. If set to ``True``, Oracle Managed Files (OMF) tablespaces will be used.
  601. :setting:`DATAFILE` and :setting:`DATAFILE_TMP` will be ignored.
  602. .. setting:: TEST_TBLSPACE
  603. ``TBLSPACE``
  604. ^^^^^^^^^^^^
  605. Default: ``None``
  606. This is an Oracle-specific setting.
  607. The name of the tablespace that will be used when running tests. If not
  608. provided, Django will use ``'test_' + USER``.
  609. .. setting:: TEST_TBLSPACE_TMP
  610. ``TBLSPACE_TMP``
  611. ^^^^^^^^^^^^^^^^
  612. Default: ``None``
  613. This is an Oracle-specific setting.
  614. The name of the temporary tablespace that will be used when running tests. If
  615. not provided, Django will use ``'test_' + USER + '_temp'``.
  616. .. setting:: DATAFILE
  617. ``DATAFILE``
  618. ^^^^^^^^^^^^
  619. Default: ``None``
  620. This is an Oracle-specific setting.
  621. The name of the datafile to use for the TBLSPACE. If not provided, Django will
  622. use ``TBLSPACE + '.dbf'``.
  623. .. setting:: DATAFILE_TMP
  624. ``DATAFILE_TMP``
  625. ^^^^^^^^^^^^^^^^
  626. Default: ``None``
  627. This is an Oracle-specific setting.
  628. The name of the datafile to use for the TBLSPACE_TMP. If not provided, Django
  629. will use ``TBLSPACE_TMP + '.dbf'``.
  630. .. setting:: DATAFILE_MAXSIZE
  631. ``DATAFILE_MAXSIZE``
  632. ^^^^^^^^^^^^^^^^^^^^
  633. Default: ``'500M'``
  634. This is an Oracle-specific setting.
  635. The maximum size that the DATAFILE is allowed to grow to.
  636. .. setting:: DATAFILE_TMP_MAXSIZE
  637. ``DATAFILE_TMP_MAXSIZE``
  638. ^^^^^^^^^^^^^^^^^^^^^^^^
  639. Default: ``'500M'``
  640. This is an Oracle-specific setting.
  641. The maximum size that the DATAFILE_TMP is allowed to grow to.
  642. .. setting:: DATAFILE_SIZE
  643. ``DATAFILE_SIZE``
  644. ^^^^^^^^^^^^^^^^^
  645. Default: ``'50M'``
  646. This is an Oracle-specific setting.
  647. The initial size of the DATAFILE.
  648. .. setting:: DATAFILE_TMP_SIZE
  649. ``DATAFILE_TMP_SIZE``
  650. ^^^^^^^^^^^^^^^^^^^^^
  651. Default: ``'50M'``
  652. This is an Oracle-specific setting.
  653. The initial size of the DATAFILE_TMP.
  654. .. setting:: DATAFILE_EXTSIZE
  655. ``DATAFILE_EXTSIZE``
  656. ^^^^^^^^^^^^^^^^^^^^
  657. Default: ``'25M'``
  658. This is an Oracle-specific setting.
  659. The amount by which the DATAFILE is extended when more space is required.
  660. .. setting:: DATAFILE_TMP_EXTSIZE
  661. ``DATAFILE_TMP_EXTSIZE``
  662. ^^^^^^^^^^^^^^^^^^^^^^^^
  663. Default: ``'25M'``
  664. This is an Oracle-specific setting.
  665. The amount by which the DATAFILE_TMP is extended when more space is required.
  666. .. setting:: DATA_UPLOAD_MAX_MEMORY_SIZE
  667. DATA_UPLOAD_MAX_MEMORY_SIZE
  668. ---------------------------
  669. Default: ``2621440`` (i.e. 2.5 MB).
  670. The maximum size in bytes that a request body may be before a
  671. :exc:`~django.core.exceptions.SuspiciousOperation` (``RequestDataTooBig``) is
  672. raised. The check is done when accessing ``request.body`` or ``request.POST``
  673. and is calculated against the total request size excluding any file upload
  674. data. You can set this to ``None`` to disable the check. Applications that are
  675. expected to receive unusually large form posts should tune this setting.
  676. The amount of request data is correlated to the amount of memory needed to
  677. process the request and populate the GET and POST dictionaries. Large requests
  678. could be used as a denial-of-service attack vector if left unchecked. Since web
  679. servers don't typically perform deep request inspection, it's not possible to
  680. perform a similar check at that level.
  681. See also :setting:`FILE_UPLOAD_MAX_MEMORY_SIZE`.
  682. .. setting:: DATA_UPLOAD_MAX_NUMBER_FIELDS
  683. DATA_UPLOAD_MAX_NUMBER_FIELDS
  684. -----------------------------
  685. Default: ``1000``
  686. The maximum number of parameters that may be received via GET or POST before a
  687. :exc:`~django.core.exceptions.SuspiciousOperation` (``TooManyFields``) is
  688. raised. You can set this to ``None`` to disable the check. Applications that
  689. are expected to receive an unusually large number of form fields should tune
  690. this setting.
  691. The number of request parameters is correlated to the amount of time needed to
  692. process the request and populate the GET and POST dictionaries. Large requests
  693. could be used as a denial-of-service attack vector if left unchecked. Since web
  694. servers don't typically perform deep request inspection, it's not possible to
  695. perform a similar check at that level.
  696. .. setting:: DATABASE_ROUTERS
  697. ``DATABASE_ROUTERS``
  698. --------------------
  699. Default: ``[]`` (Empty list)
  700. The list of routers that will be used to determine which database
  701. to use when performing a database query.
  702. See the documentation on :ref:`automatic database routing in multi
  703. database configurations <topics-db-multi-db-routing>`.
  704. .. setting:: DATE_FORMAT
  705. ``DATE_FORMAT``
  706. ---------------
  707. Default: ``'N j, Y'`` (e.g. ``Feb. 4, 2003``)
  708. The default formatting to use for displaying date fields in any part of the
  709. system. Note that if :setting:`USE_L10N` is set to ``True``, then the
  710. locale-dictated format has higher precedence and will be applied instead. See
  711. :tfilter:`allowed date format strings <date>`.
  712. See also :setting:`DATETIME_FORMAT`, :setting:`TIME_FORMAT` and :setting:`SHORT_DATE_FORMAT`.
  713. .. setting:: DATE_INPUT_FORMATS
  714. ``DATE_INPUT_FORMATS``
  715. ----------------------
  716. Default::
  717. [
  718. '%Y-%m-%d', '%m/%d/%Y', '%m/%d/%y', # '2006-10-25', '10/25/2006', '10/25/06'
  719. '%b %d %Y', '%b %d, %Y', # 'Oct 25 2006', 'Oct 25, 2006'
  720. '%d %b %Y', '%d %b, %Y', # '25 Oct 2006', '25 Oct, 2006'
  721. '%B %d %Y', '%B %d, %Y', # 'October 25 2006', 'October 25, 2006'
  722. '%d %B %Y', '%d %B, %Y', # '25 October 2006', '25 October, 2006'
  723. ]
  724. A list of formats that will be accepted when inputting data on a date field.
  725. Formats will be tried in order, using the first valid one. Note that these
  726. format strings use Python's :ref:`datetime module syntax
  727. <strftime-strptime-behavior>`, not the format strings from the :tfilter:`date`
  728. template filter.
  729. When :setting:`USE_L10N` is ``True``, the locale-dictated format has higher
  730. precedence and will be applied instead.
  731. See also :setting:`DATETIME_INPUT_FORMATS` and :setting:`TIME_INPUT_FORMATS`.
  732. .. setting:: DATETIME_FORMAT
  733. ``DATETIME_FORMAT``
  734. -------------------
  735. Default: ``'N j, Y, P'`` (e.g. ``Feb. 4, 2003, 4 p.m.``)
  736. The default formatting to use for displaying datetime fields in any part of the
  737. system. Note that if :setting:`USE_L10N` is set to ``True``, then the
  738. locale-dictated format has higher precedence and will be applied instead. See
  739. :tfilter:`allowed date format strings <date>`.
  740. See also :setting:`DATE_FORMAT`, :setting:`TIME_FORMAT` and :setting:`SHORT_DATETIME_FORMAT`.
  741. .. setting:: DATETIME_INPUT_FORMATS
  742. ``DATETIME_INPUT_FORMATS``
  743. --------------------------
  744. Default::
  745. [
  746. '%Y-%m-%d %H:%M:%S', # '2006-10-25 14:30:59'
  747. '%Y-%m-%d %H:%M:%S.%f', # '2006-10-25 14:30:59.000200'
  748. '%Y-%m-%d %H:%M', # '2006-10-25 14:30'
  749. '%m/%d/%Y %H:%M:%S', # '10/25/2006 14:30:59'
  750. '%m/%d/%Y %H:%M:%S.%f', # '10/25/2006 14:30:59.000200'
  751. '%m/%d/%Y %H:%M', # '10/25/2006 14:30'
  752. '%m/%d/%y %H:%M:%S', # '10/25/06 14:30:59'
  753. '%m/%d/%y %H:%M:%S.%f', # '10/25/06 14:30:59.000200'
  754. '%m/%d/%y %H:%M', # '10/25/06 14:30'
  755. ]
  756. A list of formats that will be accepted when inputting data on a datetime
  757. field. Formats will be tried in order, using the first valid one. Note that
  758. these format strings use Python's :ref:`datetime module syntax
  759. <strftime-strptime-behavior>`, not the format strings from the :tfilter:`date`
  760. template filter. Date-only formats are not included as datetime fields will
  761. automatically try :setting:`DATE_INPUT_FORMATS` in last resort.
  762. When :setting:`USE_L10N` is ``True``, the locale-dictated format has higher
  763. precedence and will be applied instead.
  764. See also :setting:`DATE_INPUT_FORMATS` and :setting:`TIME_INPUT_FORMATS`.
  765. .. versionchanged:: 3.1
  766. In older versions, the default is a list containing also date-only formats.
  767. .. setting:: DEBUG
  768. ``DEBUG``
  769. ---------
  770. Default: ``False``
  771. A boolean that turns on/off debug mode.
  772. Never deploy a site into production with :setting:`DEBUG` turned on.
  773. One of the main features of debug mode is the display of detailed error pages.
  774. If your app raises an exception when :setting:`DEBUG` is ``True``, Django will
  775. display a detailed traceback, including a lot of metadata about your
  776. environment, such as all the currently defined Django settings (from
  777. ``settings.py``).
  778. As a security measure, Django will *not* include settings that might be
  779. sensitive, such as :setting:`SECRET_KEY`. Specifically, it will exclude any
  780. setting whose name includes any of the following:
  781. * ``'API'``
  782. * ``'KEY'``
  783. * ``'PASS'``
  784. * ``'SECRET'``
  785. * ``'SIGNATURE'``
  786. * ``'TOKEN'``
  787. Note that these are *partial* matches. ``'PASS'`` will also match PASSWORD,
  788. just as ``'TOKEN'`` will also match TOKENIZED and so on.
  789. Still, note that there are always going to be sections of your debug output
  790. that are inappropriate for public consumption. File paths, configuration
  791. options and the like all give attackers extra information about your server.
  792. It is also important to remember that when running with :setting:`DEBUG`
  793. turned on, Django will remember every SQL query it executes. This is useful
  794. when you're debugging, but it'll rapidly consume memory on a production server.
  795. Finally, if :setting:`DEBUG` is ``False``, you also need to properly set
  796. the :setting:`ALLOWED_HOSTS` setting. Failing to do so will result in all
  797. requests being returned as "Bad Request (400)".
  798. .. note::
  799. The default :file:`settings.py` file created by :djadmin:`django-admin
  800. startproject <startproject>` sets ``DEBUG = True`` for convenience.
  801. .. setting:: DEBUG_PROPAGATE_EXCEPTIONS
  802. ``DEBUG_PROPAGATE_EXCEPTIONS``
  803. ------------------------------
  804. Default: ``False``
  805. If set to ``True``, Django's exception handling of view functions
  806. (:data:`~django.conf.urls.handler500`, or the debug view if :setting:`DEBUG`
  807. is ``True``) and logging of 500 responses (:ref:`django-request-logger`) is
  808. skipped and exceptions propagate upwards.
  809. This can be useful for some test setups. It shouldn't be used on a live site
  810. unless you want your web server (instead of Django) to generate "Internal
  811. Server Error" responses. In that case, make sure your server doesn't show the
  812. stack trace or other sensitive information in the response.
  813. .. setting:: DECIMAL_SEPARATOR
  814. ``DECIMAL_SEPARATOR``
  815. ---------------------
  816. Default: ``'.'`` (Dot)
  817. Default decimal separator used when formatting decimal numbers.
  818. Note that if :setting:`USE_L10N` is set to ``True``, then the locale-dictated
  819. format has higher precedence and will be applied instead.
  820. See also :setting:`NUMBER_GROUPING`, :setting:`THOUSAND_SEPARATOR` and
  821. :setting:`USE_THOUSAND_SEPARATOR`.
  822. .. setting:: DEFAULT_CHARSET
  823. ``DEFAULT_CHARSET``
  824. -------------------
  825. Default: ``'utf-8'``
  826. Default charset to use for all ``HttpResponse`` objects, if a MIME type isn't
  827. manually specified. Used when constructing the ``Content-Type`` header.
  828. .. setting:: DEFAULT_EXCEPTION_REPORTER
  829. ``DEFAULT_EXCEPTION_REPORTER``
  830. ------------------------------
  831. .. versionadded:: 3.1
  832. Default: ``'``:class:`django.views.debug.ExceptionReporter`\ ``'``
  833. Default exception reporter class to be used if none has been assigned to the
  834. :class:`~django.http.HttpRequest` instance yet. See
  835. :ref:`custom-error-reports`.
  836. .. setting:: DEFAULT_EXCEPTION_REPORTER_FILTER
  837. ``DEFAULT_EXCEPTION_REPORTER_FILTER``
  838. -------------------------------------
  839. Default: ``'``:class:`django.views.debug.SafeExceptionReporterFilter`\ ``'``
  840. Default exception reporter filter class to be used if none has been assigned to
  841. the :class:`~django.http.HttpRequest` instance yet.
  842. See :ref:`Filtering error reports<filtering-error-reports>`.
  843. .. setting:: DEFAULT_FILE_STORAGE
  844. ``DEFAULT_FILE_STORAGE``
  845. ------------------------
  846. Default: ``'``:class:`django.core.files.storage.FileSystemStorage`\ ``'``
  847. Default file storage class to be used for any file-related operations that don't
  848. specify a particular storage system. See :doc:`/topics/files`.
  849. .. setting:: DEFAULT_FROM_EMAIL
  850. ``DEFAULT_FROM_EMAIL``
  851. ----------------------
  852. Default: ``'webmaster@localhost'``
  853. Default email address to use for various automated correspondence from the
  854. site manager(s). This doesn't include error messages sent to :setting:`ADMINS`
  855. and :setting:`MANAGERS`; for that, see :setting:`SERVER_EMAIL`.
  856. .. setting:: DEFAULT_INDEX_TABLESPACE
  857. ``DEFAULT_INDEX_TABLESPACE``
  858. ----------------------------
  859. Default: ``''`` (Empty string)
  860. Default tablespace to use for indexes on fields that don't specify
  861. one, if the backend supports it (see :doc:`/topics/db/tablespaces`).
  862. .. setting:: DEFAULT_TABLESPACE
  863. ``DEFAULT_TABLESPACE``
  864. ----------------------
  865. Default: ``''`` (Empty string)
  866. Default tablespace to use for models that don't specify one, if the
  867. backend supports it (see :doc:`/topics/db/tablespaces`).
  868. .. setting:: DISALLOWED_USER_AGENTS
  869. ``DISALLOWED_USER_AGENTS``
  870. --------------------------
  871. Default: ``[]`` (Empty list)
  872. List of compiled regular expression objects representing User-Agent strings
  873. that are not allowed to visit any page, systemwide. Use this for bots/crawlers.
  874. This is only used if ``CommonMiddleware`` is installed (see
  875. :doc:`/topics/http/middleware`).
  876. .. setting:: EMAIL_BACKEND
  877. ``EMAIL_BACKEND``
  878. -----------------
  879. Default: ``'``:class:`django.core.mail.backends.smtp.EmailBackend`\ ``'``
  880. The backend to use for sending emails. For the list of available backends see
  881. :doc:`/topics/email`.
  882. .. setting:: EMAIL_FILE_PATH
  883. ``EMAIL_FILE_PATH``
  884. -------------------
  885. Default: Not defined
  886. The directory used by the :ref:`file email backend <topic-email-file-backend>`
  887. to store output files.
  888. .. versionchanged:: 3.1
  889. Support for :class:`pathlib.Path` was added.
  890. .. setting:: EMAIL_HOST
  891. ``EMAIL_HOST``
  892. --------------
  893. Default: ``'localhost'``
  894. The host to use for sending email.
  895. See also :setting:`EMAIL_PORT`.
  896. .. setting:: EMAIL_HOST_PASSWORD
  897. ``EMAIL_HOST_PASSWORD``
  898. -----------------------
  899. Default: ``''`` (Empty string)
  900. Password to use for the SMTP server defined in :setting:`EMAIL_HOST`. This
  901. setting is used in conjunction with :setting:`EMAIL_HOST_USER` when
  902. authenticating to the SMTP server. If either of these settings is empty,
  903. Django won't attempt authentication.
  904. See also :setting:`EMAIL_HOST_USER`.
  905. .. setting:: EMAIL_HOST_USER
  906. ``EMAIL_HOST_USER``
  907. -------------------
  908. Default: ``''`` (Empty string)
  909. Username to use for the SMTP server defined in :setting:`EMAIL_HOST`.
  910. If empty, Django won't attempt authentication.
  911. See also :setting:`EMAIL_HOST_PASSWORD`.
  912. .. setting:: EMAIL_PORT
  913. ``EMAIL_PORT``
  914. --------------
  915. Default: ``25``
  916. Port to use for the SMTP server defined in :setting:`EMAIL_HOST`.
  917. .. setting:: EMAIL_SUBJECT_PREFIX
  918. ``EMAIL_SUBJECT_PREFIX``
  919. ------------------------
  920. Default: ``'[Django] '``
  921. Subject-line prefix for email messages sent with ``django.core.mail.mail_admins``
  922. or ``django.core.mail.mail_managers``. You'll probably want to include the
  923. trailing space.
  924. .. setting:: EMAIL_USE_LOCALTIME
  925. ``EMAIL_USE_LOCALTIME``
  926. -----------------------
  927. Default: ``False``
  928. Whether to send the SMTP ``Date`` header of email messages in the local time
  929. zone (``True``) or in UTC (``False``).
  930. .. setting:: EMAIL_USE_TLS
  931. ``EMAIL_USE_TLS``
  932. -----------------
  933. Default: ``False``
  934. Whether to use a TLS (secure) connection when talking to the SMTP server.
  935. This is used for explicit TLS connections, generally on port 587. If you are
  936. experiencing hanging connections, see the implicit TLS setting
  937. :setting:`EMAIL_USE_SSL`.
  938. .. setting:: EMAIL_USE_SSL
  939. ``EMAIL_USE_SSL``
  940. -----------------
  941. Default: ``False``
  942. Whether to use an implicit TLS (secure) connection when talking to the SMTP
  943. server. In most email documentation this type of TLS connection is referred
  944. to as SSL. It is generally used on port 465. If you are experiencing problems,
  945. see the explicit TLS setting :setting:`EMAIL_USE_TLS`.
  946. Note that :setting:`EMAIL_USE_TLS`/:setting:`EMAIL_USE_SSL` are mutually
  947. exclusive, so only set one of those settings to ``True``.
  948. .. setting:: EMAIL_SSL_CERTFILE
  949. ``EMAIL_SSL_CERTFILE``
  950. ----------------------
  951. Default: ``None``
  952. If :setting:`EMAIL_USE_SSL` or :setting:`EMAIL_USE_TLS` is ``True``, you can
  953. optionally specify the path to a PEM-formatted certificate chain file to use
  954. for the SSL connection.
  955. .. setting:: EMAIL_SSL_KEYFILE
  956. ``EMAIL_SSL_KEYFILE``
  957. ---------------------
  958. Default: ``None``
  959. If :setting:`EMAIL_USE_SSL` or :setting:`EMAIL_USE_TLS` is ``True``, you can
  960. optionally specify the path to a PEM-formatted private key file to use for the
  961. SSL connection.
  962. Note that setting :setting:`EMAIL_SSL_CERTFILE` and :setting:`EMAIL_SSL_KEYFILE`
  963. doesn't result in any certificate checking. They're passed to the underlying SSL
  964. connection. Please refer to the documentation of Python's
  965. :func:`python:ssl.wrap_socket` function for details on how the certificate chain
  966. file and private key file are handled.
  967. .. setting:: EMAIL_TIMEOUT
  968. ``EMAIL_TIMEOUT``
  969. -----------------
  970. Default: ``None``
  971. Specifies a timeout in seconds for blocking operations like the connection
  972. attempt.
  973. .. setting:: FILE_UPLOAD_HANDLERS
  974. ``FILE_UPLOAD_HANDLERS``
  975. ------------------------
  976. Default::
  977. [
  978. 'django.core.files.uploadhandler.MemoryFileUploadHandler',
  979. 'django.core.files.uploadhandler.TemporaryFileUploadHandler',
  980. ]
  981. A list of handlers to use for uploading. Changing this setting allows complete
  982. customization -- even replacement -- of Django's upload process.
  983. See :doc:`/topics/files` for details.
  984. .. setting:: FILE_UPLOAD_MAX_MEMORY_SIZE
  985. ``FILE_UPLOAD_MAX_MEMORY_SIZE``
  986. -------------------------------
  987. Default: ``2621440`` (i.e. 2.5 MB).
  988. The maximum size (in bytes) that an upload will be before it gets streamed to
  989. the file system. See :doc:`/topics/files` for details.
  990. See also :setting:`DATA_UPLOAD_MAX_MEMORY_SIZE`.
  991. .. setting:: FILE_UPLOAD_DIRECTORY_PERMISSIONS
  992. ``FILE_UPLOAD_DIRECTORY_PERMISSIONS``
  993. -------------------------------------
  994. Default: ``None``
  995. The numeric mode to apply to directories created in the process of uploading
  996. files.
  997. This setting also determines the default permissions for collected static
  998. directories when using the :djadmin:`collectstatic` management command. See
  999. :djadmin:`collectstatic` for details on overriding it.
  1000. This value mirrors the functionality and caveats of the
  1001. :setting:`FILE_UPLOAD_PERMISSIONS` setting.
  1002. .. setting:: FILE_UPLOAD_PERMISSIONS
  1003. ``FILE_UPLOAD_PERMISSIONS``
  1004. ---------------------------
  1005. Default: ``0o644``
  1006. The numeric mode (i.e. ``0o644``) to set newly uploaded files to. For
  1007. more information about what these modes mean, see the documentation for
  1008. :func:`os.chmod`.
  1009. If this isn't given or is ``None``, you'll get operating-system
  1010. dependent behavior. On most platforms, temporary files will have a mode
  1011. of ``0o600``, and files saved from memory will be saved using the
  1012. system's standard umask.
  1013. For security reasons, these permissions aren't applied to the temporary files
  1014. that are stored in :setting:`FILE_UPLOAD_TEMP_DIR`.
  1015. This setting also determines the default permissions for collected static files
  1016. when using the :djadmin:`collectstatic` management command. See
  1017. :djadmin:`collectstatic` for details on overriding it.
  1018. .. warning::
  1019. **Always prefix the mode with a 0.**
  1020. If you're not familiar with file modes, please note that the leading
  1021. ``0`` is very important: it indicates an octal number, which is the
  1022. way that modes must be specified. If you try to use ``644``, you'll
  1023. get totally incorrect behavior.
  1024. .. setting:: FILE_UPLOAD_TEMP_DIR
  1025. ``FILE_UPLOAD_TEMP_DIR``
  1026. ------------------------
  1027. Default: ``None``
  1028. The directory to store data to (typically files larger than
  1029. :setting:`FILE_UPLOAD_MAX_MEMORY_SIZE`) temporarily while uploading files.
  1030. If ``None``, Django will use the standard temporary directory for the operating
  1031. system. For example, this will default to ``/tmp`` on \*nix-style operating
  1032. systems.
  1033. See :doc:`/topics/files` for details.
  1034. .. setting:: FIRST_DAY_OF_WEEK
  1035. ``FIRST_DAY_OF_WEEK``
  1036. ---------------------
  1037. Default: ``0`` (Sunday)
  1038. A number representing the first day of the week. This is especially useful
  1039. when displaying a calendar. This value is only used when not using
  1040. format internationalization, or when a format cannot be found for the
  1041. current locale.
  1042. The value must be an integer from 0 to 6, where 0 means Sunday, 1 means
  1043. Monday and so on.
  1044. .. setting:: FIXTURE_DIRS
  1045. ``FIXTURE_DIRS``
  1046. ----------------
  1047. Default: ``[]`` (Empty list)
  1048. List of directories searched for fixture files, in addition to the
  1049. ``fixtures`` directory of each application, in search order.
  1050. Note that these paths should use Unix-style forward slashes, even on Windows.
  1051. See :ref:`initial-data-via-fixtures` and :ref:`topics-testing-fixtures`.
  1052. .. setting:: FORCE_SCRIPT_NAME
  1053. ``FORCE_SCRIPT_NAME``
  1054. ---------------------
  1055. Default: ``None``
  1056. If not ``None``, this will be used as the value of the ``SCRIPT_NAME``
  1057. environment variable in any HTTP request. This setting can be used to override
  1058. the server-provided value of ``SCRIPT_NAME``, which may be a rewritten version
  1059. of the preferred value or not supplied at all. It is also used by
  1060. :func:`django.setup()` to set the URL resolver script prefix outside of the
  1061. request/response cycle (e.g. in management commands and standalone scripts) to
  1062. generate correct URLs when ``SCRIPT_NAME`` is not ``/``.
  1063. .. setting:: FORM_RENDERER
  1064. ``FORM_RENDERER``
  1065. -----------------
  1066. Default: ``'``:class:`django.forms.renderers.DjangoTemplates`\ ``'``
  1067. The class that renders form widgets. It must implement :ref:`the low-level
  1068. render API <low-level-widget-render-api>`.
  1069. .. setting:: FORMAT_MODULE_PATH
  1070. ``FORMAT_MODULE_PATH``
  1071. ----------------------
  1072. Default: ``None``
  1073. A full Python path to a Python package that contains custom format definitions
  1074. for project locales. If not ``None``, Django will check for a ``formats.py``
  1075. file, under the directory named as the current locale, and will use the
  1076. formats defined in this file.
  1077. For example, if :setting:`FORMAT_MODULE_PATH` is set to ``mysite.formats``,
  1078. and current language is ``en`` (English), Django will expect a directory tree
  1079. like::
  1080. mysite/
  1081. formats/
  1082. __init__.py
  1083. en/
  1084. __init__.py
  1085. formats.py
  1086. You can also set this setting to a list of Python paths, for example::
  1087. FORMAT_MODULE_PATH = [
  1088. 'mysite.formats',
  1089. 'some_app.formats',
  1090. ]
  1091. When Django searches for a certain format, it will go through all given Python
  1092. paths until it finds a module that actually defines the given format. This
  1093. means that formats defined in packages farther up in the list will take
  1094. precedence over the same formats in packages farther down.
  1095. Available formats are:
  1096. * :setting:`DATE_FORMAT`
  1097. * :setting:`DATE_INPUT_FORMATS`
  1098. * :setting:`DATETIME_FORMAT`,
  1099. * :setting:`DATETIME_INPUT_FORMATS`
  1100. * :setting:`DECIMAL_SEPARATOR`
  1101. * :setting:`FIRST_DAY_OF_WEEK`
  1102. * :setting:`MONTH_DAY_FORMAT`
  1103. * :setting:`NUMBER_GROUPING`
  1104. * :setting:`SHORT_DATE_FORMAT`
  1105. * :setting:`SHORT_DATETIME_FORMAT`
  1106. * :setting:`THOUSAND_SEPARATOR`
  1107. * :setting:`TIME_FORMAT`
  1108. * :setting:`TIME_INPUT_FORMATS`
  1109. * :setting:`YEAR_MONTH_FORMAT`
  1110. .. setting:: IGNORABLE_404_URLS
  1111. ``IGNORABLE_404_URLS``
  1112. ----------------------
  1113. Default: ``[]`` (Empty list)
  1114. List of compiled regular expression objects describing URLs that should be
  1115. ignored when reporting HTTP 404 errors via email (see
  1116. :doc:`/howto/error-reporting`). Regular expressions are matched against
  1117. :meth:`request's full paths <django.http.HttpRequest.get_full_path>` (including
  1118. query string, if any). Use this if your site does not provide a commonly
  1119. requested file such as ``favicon.ico`` or ``robots.txt``.
  1120. This is only used if
  1121. :class:`~django.middleware.common.BrokenLinkEmailsMiddleware` is enabled (see
  1122. :doc:`/topics/http/middleware`).
  1123. .. setting:: INSTALLED_APPS
  1124. ``INSTALLED_APPS``
  1125. ------------------
  1126. Default: ``[]`` (Empty list)
  1127. A list of strings designating all applications that are enabled in this
  1128. Django installation. Each string should be a dotted Python path to:
  1129. * an application configuration class (preferred), or
  1130. * a package containing an application.
  1131. :doc:`Learn more about application configurations </ref/applications>`.
  1132. .. admonition:: Use the application registry for introspection
  1133. Your code should never access :setting:`INSTALLED_APPS` directly. Use
  1134. :attr:`django.apps.apps` instead.
  1135. .. admonition:: Application names and labels must be unique in
  1136. :setting:`INSTALLED_APPS`
  1137. Application :attr:`names <django.apps.AppConfig.name>` — the dotted Python
  1138. path to the application package — must be unique. There is no way to
  1139. include the same application twice, short of duplicating its code under
  1140. another name.
  1141. Application :attr:`labels <django.apps.AppConfig.label>` — by default the
  1142. final part of the name — must be unique too. For example, you can't
  1143. include both ``django.contrib.auth`` and ``myproject.auth``. However, you
  1144. can relabel an application with a custom configuration that defines a
  1145. different :attr:`~django.apps.AppConfig.label`.
  1146. These rules apply regardless of whether :setting:`INSTALLED_APPS`
  1147. references application configuration classes or application packages.
  1148. When several applications provide different versions of the same resource
  1149. (template, static file, management command, translation), the application
  1150. listed first in :setting:`INSTALLED_APPS` has precedence.
  1151. .. setting:: INTERNAL_IPS
  1152. ``INTERNAL_IPS``
  1153. ----------------
  1154. Default: ``[]`` (Empty list)
  1155. A list of IP addresses, as strings, that:
  1156. * Allow the :func:`~django.template.context_processors.debug` context processor
  1157. to add some variables to the template context.
  1158. * Can use the :ref:`admindocs bookmarklets <admindocs-bookmarklets>` even if
  1159. not logged in as a staff user.
  1160. * Are marked as "internal" (as opposed to "EXTERNAL") in
  1161. :class:`~django.utils.log.AdminEmailHandler` emails.
  1162. .. setting:: LANGUAGE_CODE
  1163. ``LANGUAGE_CODE``
  1164. -----------------
  1165. Default: ``'en-us'``
  1166. A string representing the language code for this installation. This should be in
  1167. standard :term:`language ID format <language code>`. For example, U.S. English
  1168. is ``"en-us"``. See also the `list of language identifiers`_ and
  1169. :doc:`/topics/i18n/index`.
  1170. :setting:`USE_I18N` must be active for this setting to have any effect.
  1171. It serves two purposes:
  1172. * If the locale middleware isn't in use, it decides which translation is served
  1173. to all users.
  1174. * If the locale middleware is active, it provides a fallback language in case the
  1175. user's preferred language can't be determined or is not supported by the
  1176. website. It also provides the fallback translation when a translation for a
  1177. given literal doesn't exist for the user's preferred language.
  1178. See :ref:`how-django-discovers-language-preference` for more details.
  1179. .. _list of language identifiers: http://www.i18nguy.com/unicode/language-identifiers.html
  1180. .. setting:: LANGUAGE_COOKIE_AGE
  1181. ``LANGUAGE_COOKIE_AGE``
  1182. -----------------------
  1183. Default: ``None`` (expires at browser close)
  1184. The age of the language cookie, in seconds.
  1185. .. setting:: LANGUAGE_COOKIE_DOMAIN
  1186. ``LANGUAGE_COOKIE_DOMAIN``
  1187. --------------------------
  1188. Default: ``None``
  1189. The domain to use for the language cookie. Set this to a string such as
  1190. ``"example.com"`` for cross-domain cookies, or use ``None`` for a standard
  1191. domain cookie.
  1192. Be cautious when updating this setting on a production site. If you update
  1193. this setting to enable cross-domain cookies on a site that previously used
  1194. standard domain cookies, existing user cookies that have the old domain
  1195. will not be updated. This will result in site users being unable to switch
  1196. the language as long as these cookies persist. The only safe and reliable
  1197. option to perform the switch is to change the language cookie name
  1198. permanently (via the :setting:`LANGUAGE_COOKIE_NAME` setting) and to add
  1199. a middleware that copies the value from the old cookie to a new one and then
  1200. deletes the old one.
  1201. .. setting:: LANGUAGE_COOKIE_HTTPONLY
  1202. ``LANGUAGE_COOKIE_HTTPONLY``
  1203. ----------------------------
  1204. Default: ``False``
  1205. Whether to use ``HttpOnly`` flag on the language cookie. If this is set to
  1206. ``True``, client-side JavaScript will not be able to access the language
  1207. cookie.
  1208. See :setting:`SESSION_COOKIE_HTTPONLY` for details on ``HttpOnly``.
  1209. .. setting:: LANGUAGE_COOKIE_NAME
  1210. ``LANGUAGE_COOKIE_NAME``
  1211. ------------------------
  1212. Default: ``'django_language'``
  1213. The name of the cookie to use for the language cookie. This can be whatever
  1214. you want (as long as it's different from the other cookie names in your
  1215. application). See :doc:`/topics/i18n/index`.
  1216. .. setting:: LANGUAGE_COOKIE_PATH
  1217. ``LANGUAGE_COOKIE_PATH``
  1218. ------------------------
  1219. Default: ``'/'``
  1220. The path set on the language cookie. This should either match the URL path of your
  1221. Django installation or be a parent of that path.
  1222. This is useful if you have multiple Django instances running under the same
  1223. hostname. They can use different cookie paths and each instance will only see
  1224. its own language cookie.
  1225. Be cautious when updating this setting on a production site. If you update this
  1226. setting to use a deeper path than it previously used, existing user cookies that
  1227. have the old path will not be updated. This will result in site users being
  1228. unable to switch the language as long as these cookies persist. The only safe
  1229. and reliable option to perform the switch is to change the language cookie name
  1230. permanently (via the :setting:`LANGUAGE_COOKIE_NAME` setting), and to add
  1231. a middleware that copies the value from the old cookie to a new one and then
  1232. deletes the one.
  1233. .. setting:: LANGUAGE_COOKIE_SAMESITE
  1234. ``LANGUAGE_COOKIE_SAMESITE``
  1235. ----------------------------
  1236. Default: ``None``
  1237. The value of the `SameSite`_ flag on the language cookie. This flag prevents the
  1238. cookie from being sent in cross-site requests.
  1239. See :setting:`SESSION_COOKIE_SAMESITE` for details about ``SameSite``.
  1240. .. versionchanged:: 3.1
  1241. Setting ``LANGUAGE_COOKIE_SAMESITE = 'None'`` was allowed.
  1242. .. setting:: LANGUAGE_COOKIE_SECURE
  1243. ``LANGUAGE_COOKIE_SECURE``
  1244. --------------------------
  1245. Default: ``False``
  1246. Whether to use a secure cookie for the language cookie. If this is set to
  1247. ``True``, the cookie will be marked as "secure", which means browsers may
  1248. ensure that the cookie is only sent under an HTTPS connection.
  1249. .. setting:: LANGUAGES
  1250. ``LANGUAGES``
  1251. -------------
  1252. Default: A list of all available languages. This list is continually growing
  1253. and including a copy here would inevitably become rapidly out of date. You can
  1254. see the current list of translated languages by looking in
  1255. :source:`django/conf/global_settings.py`.
  1256. The list is a list of two-tuples in the format
  1257. (:term:`language code<language code>`, ``language name``) -- for example,
  1258. ``('ja', 'Japanese')``.
  1259. This specifies which languages are available for language selection. See
  1260. :doc:`/topics/i18n/index`.
  1261. Generally, the default value should suffice. Only set this setting if you want
  1262. to restrict language selection to a subset of the Django-provided languages.
  1263. If you define a custom :setting:`LANGUAGES` setting, you can mark the
  1264. language names as translation strings using the
  1265. :func:`~django.utils.translation.gettext_lazy` function.
  1266. Here's a sample settings file::
  1267. from django.utils.translation import gettext_lazy as _
  1268. LANGUAGES = [
  1269. ('de', _('German')),
  1270. ('en', _('English')),
  1271. ]
  1272. .. setting:: LANGUAGES_BIDI
  1273. ``LANGUAGES_BIDI``
  1274. ------------------
  1275. Default: A list of all language codes that are written right-to-left. You can
  1276. see the current list of these languages by looking in
  1277. :source:`django/conf/global_settings.py`.
  1278. The list contains :term:`language codes<language code>` for languages that are
  1279. written right-to-left.
  1280. Generally, the default value should suffice. Only set this setting if you want
  1281. to restrict language selection to a subset of the Django-provided languages.
  1282. If you define a custom :setting:`LANGUAGES` setting, the list of bidirectional
  1283. languages may contain language codes which are not enabled on a given site.
  1284. .. setting:: LOCALE_PATHS
  1285. ``LOCALE_PATHS``
  1286. ----------------
  1287. Default: ``[]`` (Empty list)
  1288. A list of directories where Django looks for translation files.
  1289. See :ref:`how-django-discovers-translations`.
  1290. Example::
  1291. LOCALE_PATHS = [
  1292. '/home/www/project/common_files/locale',
  1293. '/var/local/translations/locale',
  1294. ]
  1295. Django will look within each of these paths for the ``<locale_code>/LC_MESSAGES``
  1296. directories containing the actual translation files.
  1297. .. setting:: LOGGING
  1298. ``LOGGING``
  1299. -----------
  1300. Default: A logging configuration dictionary.
  1301. A data structure containing configuration information. The contents of
  1302. this data structure will be passed as the argument to the
  1303. configuration method described in :setting:`LOGGING_CONFIG`.
  1304. Among other things, the default logging configuration passes HTTP 500 server
  1305. errors to an email log handler when :setting:`DEBUG` is ``False``. See also
  1306. :ref:`configuring-logging`.
  1307. You can see the default logging configuration by looking in
  1308. :source:`django/utils/log.py`.
  1309. .. setting:: LOGGING_CONFIG
  1310. ``LOGGING_CONFIG``
  1311. ------------------
  1312. Default: ``'logging.config.dictConfig'``
  1313. A path to a callable that will be used to configure logging in the
  1314. Django project. Points at an instance of Python's :ref:`dictConfig
  1315. <logging-config-dictschema>` configuration method by default.
  1316. If you set :setting:`LOGGING_CONFIG` to ``None``, the logging
  1317. configuration process will be skipped.
  1318. .. setting:: MANAGERS
  1319. ``MANAGERS``
  1320. ------------
  1321. Default: ``[]`` (Empty list)
  1322. A list in the same format as :setting:`ADMINS` that specifies who should get
  1323. broken link notifications when
  1324. :class:`~django.middleware.common.BrokenLinkEmailsMiddleware` is enabled.
  1325. .. setting:: MEDIA_ROOT
  1326. ``MEDIA_ROOT``
  1327. --------------
  1328. Default: ``''`` (Empty string)
  1329. Absolute filesystem path to the directory that will hold :doc:`user-uploaded
  1330. files </topics/files>`.
  1331. Example: ``"/var/www/example.com/media/"``
  1332. See also :setting:`MEDIA_URL`.
  1333. .. warning::
  1334. :setting:`MEDIA_ROOT` and :setting:`STATIC_ROOT` must have different
  1335. values. Before :setting:`STATIC_ROOT` was introduced, it was common to
  1336. rely or fallback on :setting:`MEDIA_ROOT` to also serve static files;
  1337. however, since this can have serious security implications, there is a
  1338. validation check to prevent it.
  1339. .. setting:: MEDIA_URL
  1340. ``MEDIA_URL``
  1341. -------------
  1342. Default: ``''`` (Empty string)
  1343. URL that handles the media served from :setting:`MEDIA_ROOT`, used
  1344. for :doc:`managing stored files </topics/files>`. It must end in a slash if set
  1345. to a non-empty value. You will need to :ref:`configure these files to be served
  1346. <serving-uploaded-files-in-development>` in both development and production
  1347. environments.
  1348. If you want to use ``{{ MEDIA_URL }}`` in your templates, add
  1349. ``'django.template.context_processors.media'`` in the ``'context_processors'``
  1350. option of :setting:`TEMPLATES`.
  1351. Example: ``"http://media.example.com/"``
  1352. .. warning::
  1353. There are security risks if you are accepting uploaded content from
  1354. untrusted users! See the security guide's topic on
  1355. :ref:`user-uploaded-content-security` for mitigation details.
  1356. .. warning::
  1357. :setting:`MEDIA_URL` and :setting:`STATIC_URL` must have different
  1358. values. See :setting:`MEDIA_ROOT` for more details.
  1359. .. note::
  1360. If :setting:`MEDIA_URL` is a relative path, then it will be prefixed by the
  1361. server-provided value of ``SCRIPT_NAME`` (or ``/`` if not set). This makes
  1362. it easier to serve a Django application in a subpath without adding an
  1363. extra configuration to the settings.
  1364. .. setting:: MIDDLEWARE
  1365. ``MIDDLEWARE``
  1366. --------------
  1367. Default: ``None``
  1368. A list of middleware to use. See :doc:`/topics/http/middleware`.
  1369. .. setting:: MIGRATION_MODULES
  1370. ``MIGRATION_MODULES``
  1371. ---------------------
  1372. Default: ``{}`` (Empty dictionary)
  1373. A dictionary specifying the package where migration modules can be found on a
  1374. per-app basis. The default value of this setting is an empty dictionary, but
  1375. the default package name for migration modules is ``migrations``.
  1376. Example::
  1377. {'blog': 'blog.db_migrations'}
  1378. In this case, migrations pertaining to the ``blog`` app will be contained in
  1379. the ``blog.db_migrations`` package.
  1380. If you provide the ``app_label`` argument, :djadmin:`makemigrations` will
  1381. automatically create the package if it doesn't already exist.
  1382. When you supply ``None`` as a value for an app, Django will consider the app as
  1383. an app without migrations regardless of an existing ``migrations`` submodule.
  1384. This can be used, for example, in a test settings file to skip migrations while
  1385. testing (tables will still be created for the apps' models). To disable
  1386. migrations for all apps during tests, you can set the
  1387. :setting:`MIGRATE <TEST_MIGRATE>` to ``False`` instead. If
  1388. ``MIGRATION_MODULES`` is used in your general project settings, remember to use
  1389. the :option:`migrate --run-syncdb` option if you want to create tables for the
  1390. app.
  1391. .. setting:: MONTH_DAY_FORMAT
  1392. ``MONTH_DAY_FORMAT``
  1393. --------------------
  1394. Default: ``'F j'``
  1395. The default formatting to use for date fields on Django admin change-list
  1396. pages -- and, possibly, by other parts of the system -- in cases when only the
  1397. month and day are displayed.
  1398. For example, when a Django admin change-list page is being filtered by a date
  1399. drilldown, the header for a given day displays the day and month. Different
  1400. locales have different formats. For example, U.S. English would say
  1401. "January 1," whereas Spanish might say "1 Enero."
  1402. Note that if :setting:`USE_L10N` is set to ``True``, then the corresponding
  1403. locale-dictated format has higher precedence and will be applied.
  1404. See :tfilter:`allowed date format strings <date>`. See also
  1405. :setting:`DATE_FORMAT`, :setting:`DATETIME_FORMAT`,
  1406. :setting:`TIME_FORMAT` and :setting:`YEAR_MONTH_FORMAT`.
  1407. .. setting:: NUMBER_GROUPING
  1408. ``NUMBER_GROUPING``
  1409. -------------------
  1410. Default: ``0``
  1411. Number of digits grouped together on the integer part of a number.
  1412. Common use is to display a thousand separator. If this setting is ``0``, then
  1413. no grouping will be applied to the number. If this setting is greater than
  1414. ``0``, then :setting:`THOUSAND_SEPARATOR` will be used as the separator between
  1415. those groups.
  1416. Some locales use non-uniform digit grouping, e.g. ``10,00,00,000`` in
  1417. ``en_IN``. For this case, you can provide a sequence with the number of digit
  1418. group sizes to be applied. The first number defines the size of the group
  1419. preceding the decimal delimiter, and each number that follows defines the size
  1420. of preceding groups. If the sequence is terminated with ``-1``, no further
  1421. grouping is performed. If the sequence terminates with a ``0``, the last group
  1422. size is used for the remainder of the number.
  1423. Example tuple for ``en_IN``::
  1424. NUMBER_GROUPING = (3, 2, 0)
  1425. Note that if :setting:`USE_L10N` is set to ``True``, then the locale-dictated
  1426. format has higher precedence and will be applied instead.
  1427. See also :setting:`DECIMAL_SEPARATOR`, :setting:`THOUSAND_SEPARATOR` and
  1428. :setting:`USE_THOUSAND_SEPARATOR`.
  1429. .. setting:: PREPEND_WWW
  1430. ``PREPEND_WWW``
  1431. ---------------
  1432. Default: ``False``
  1433. Whether to prepend the "www." subdomain to URLs that don't have it. This is only
  1434. used if :class:`~django.middleware.common.CommonMiddleware` is installed
  1435. (see :doc:`/topics/http/middleware`). See also :setting:`APPEND_SLASH`.
  1436. .. setting:: ROOT_URLCONF
  1437. ``ROOT_URLCONF``
  1438. ----------------
  1439. Default: Not defined
  1440. A string representing the full Python import path to your root URLconf, for
  1441. example ``"mydjangoapps.urls"``. Can be overridden on a per-request basis by
  1442. setting the attribute ``urlconf`` on the incoming ``HttpRequest``
  1443. object. See :ref:`how-django-processes-a-request` for details.
  1444. .. setting:: SECRET_KEY
  1445. ``SECRET_KEY``
  1446. --------------
  1447. Default: ``''`` (Empty string)
  1448. A secret key for a particular Django installation. This is used to provide
  1449. :doc:`cryptographic signing </topics/signing>`, and should be set to a unique,
  1450. unpredictable value.
  1451. :djadmin:`django-admin startproject <startproject>` automatically adds a
  1452. randomly-generated ``SECRET_KEY`` to each new project.
  1453. Uses of the key shouldn't assume that it's text or bytes. Every use should go
  1454. through :func:`~django.utils.encoding.force_str` or
  1455. :func:`~django.utils.encoding.force_bytes` to convert it to the desired type.
  1456. Django will refuse to start if :setting:`SECRET_KEY` is not set.
  1457. .. warning::
  1458. **Keep this value secret.**
  1459. Running Django with a known :setting:`SECRET_KEY` defeats many of Django's
  1460. security protections, and can lead to privilege escalation and remote code
  1461. execution vulnerabilities.
  1462. The secret key is used for:
  1463. * All :doc:`sessions </topics/http/sessions>` if you are using
  1464. any other session backend than ``django.contrib.sessions.backends.cache``,
  1465. or are using the default
  1466. :meth:`~django.contrib.auth.models.AbstractBaseUser.get_session_auth_hash()`.
  1467. * All :doc:`messages </ref/contrib/messages>` if you are using
  1468. :class:`~django.contrib.messages.storage.cookie.CookieStorage` or
  1469. :class:`~django.contrib.messages.storage.fallback.FallbackStorage`.
  1470. * All :class:`~django.contrib.auth.views.PasswordResetView` tokens.
  1471. * Any usage of :doc:`cryptographic signing </topics/signing>`, unless a
  1472. different key is provided.
  1473. If you rotate your secret key, all of the above will be invalidated.
  1474. Secret keys are not used for passwords of users and key rotation will not
  1475. affect them.
  1476. .. note::
  1477. The default :file:`settings.py` file created by :djadmin:`django-admin
  1478. startproject <startproject>` creates a unique ``SECRET_KEY`` for
  1479. convenience.
  1480. .. setting:: SECURE_BROWSER_XSS_FILTER
  1481. ``SECURE_BROWSER_XSS_FILTER``
  1482. -----------------------------
  1483. Default: ``False``
  1484. If ``True``, the :class:`~django.middleware.security.SecurityMiddleware` sets
  1485. the :ref:`x-xss-protection` header on all responses that do not already have it.
  1486. Modern browsers don't honor ``X-XSS-Protection`` HTTP header anymore. Although
  1487. the setting offers little practical benefit, you may still want to set the
  1488. header if you support older browsers.
  1489. .. setting:: SECURE_CONTENT_TYPE_NOSNIFF
  1490. ``SECURE_CONTENT_TYPE_NOSNIFF``
  1491. -------------------------------
  1492. Default: ``True``
  1493. If ``True``, the :class:`~django.middleware.security.SecurityMiddleware`
  1494. sets the :ref:`x-content-type-options` header on all responses that do not
  1495. already have it.
  1496. .. setting:: SECURE_HSTS_INCLUDE_SUBDOMAINS
  1497. ``SECURE_HSTS_INCLUDE_SUBDOMAINS``
  1498. ----------------------------------
  1499. Default: ``False``
  1500. If ``True``, the :class:`~django.middleware.security.SecurityMiddleware` adds
  1501. the ``includeSubDomains`` directive to the :ref:`http-strict-transport-security`
  1502. header. It has no effect unless :setting:`SECURE_HSTS_SECONDS` is set to a
  1503. non-zero value.
  1504. .. warning::
  1505. Setting this incorrectly can irreversibly (for the value of
  1506. :setting:`SECURE_HSTS_SECONDS`) break your site. Read the
  1507. :ref:`http-strict-transport-security` documentation first.
  1508. .. setting:: SECURE_HSTS_PRELOAD
  1509. ``SECURE_HSTS_PRELOAD``
  1510. -----------------------
  1511. Default: ``False``
  1512. If ``True``, the :class:`~django.middleware.security.SecurityMiddleware` adds
  1513. the ``preload`` directive to the :ref:`http-strict-transport-security`
  1514. header. It has no effect unless :setting:`SECURE_HSTS_SECONDS` is set to a
  1515. non-zero value.
  1516. .. setting:: SECURE_HSTS_SECONDS
  1517. ``SECURE_HSTS_SECONDS``
  1518. -----------------------
  1519. Default: ``0``
  1520. If set to a non-zero integer value, the
  1521. :class:`~django.middleware.security.SecurityMiddleware` sets the
  1522. :ref:`http-strict-transport-security` header on all responses that do not
  1523. already have it.
  1524. .. warning::
  1525. Setting this incorrectly can irreversibly (for some time) break your site.
  1526. Read the :ref:`http-strict-transport-security` documentation first.
  1527. .. setting:: SECURE_PROXY_SSL_HEADER
  1528. ``SECURE_PROXY_SSL_HEADER``
  1529. ---------------------------
  1530. Default: ``None``
  1531. A tuple representing a HTTP header/value combination that signifies a request
  1532. is secure. This controls the behavior of the request object's ``is_secure()``
  1533. method.
  1534. By default, ``is_secure()`` determines if a request is secure by confirming
  1535. that a requested URL uses ``https://``. This method is important for Django's
  1536. CSRF protection, and it may be used by your own code or third-party apps.
  1537. If your Django app is behind a proxy, though, the proxy may be "swallowing"
  1538. whether the original request uses HTTPS or not. If there is a non-HTTPS
  1539. connection between the proxy and Django then ``is_secure()`` would always
  1540. return ``False`` -- even for requests that were made via HTTPS by the end user.
  1541. In contrast, if there is an HTTPS connection between the proxy and Django then
  1542. ``is_secure()`` would always return ``True`` -- even for requests that were
  1543. made originally via HTTP.
  1544. In this situation, configure your proxy to set a custom HTTP header that tells
  1545. Django whether the request came in via HTTPS, and set
  1546. ``SECURE_PROXY_SSL_HEADER`` so that Django knows what header to look for.
  1547. Set a tuple with two elements -- the name of the header to look for and the
  1548. required value. For example::
  1549. SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
  1550. This tells Django to trust the ``X-Forwarded-Proto`` header that comes from our
  1551. proxy, and any time its value is ``'https'``, then the request is guaranteed to
  1552. be secure (i.e., it originally came in via HTTPS).
  1553. You should *only* set this setting if you control your proxy or have some other
  1554. guarantee that it sets/strips this header appropriately.
  1555. Note that the header needs to be in the format as used by ``request.META`` --
  1556. all caps and likely starting with ``HTTP_``. (Remember, Django automatically
  1557. adds ``'HTTP_'`` to the start of x-header names before making the header
  1558. available in ``request.META``.)
  1559. .. warning::
  1560. **Modifying this setting can compromise your site's security. Ensure you
  1561. fully understand your setup before changing it.**
  1562. Make sure ALL of the following are true before setting this (assuming the
  1563. values from the example above):
  1564. * Your Django app is behind a proxy.
  1565. * Your proxy strips the ``X-Forwarded-Proto`` header from all incoming
  1566. requests. In other words, if end users include that header in their
  1567. requests, the proxy will discard it.
  1568. * Your proxy sets the ``X-Forwarded-Proto`` header and sends it to Django,
  1569. but only for requests that originally come in via HTTPS.
  1570. If any of those are not true, you should keep this setting set to ``None``
  1571. and find another way of determining HTTPS, perhaps via custom middleware.
  1572. .. setting:: SECURE_REDIRECT_EXEMPT
  1573. ``SECURE_REDIRECT_EXEMPT``
  1574. --------------------------
  1575. Default: ``[]`` (Empty list)
  1576. If a URL path matches a regular expression in this list, the request will not be
  1577. redirected to HTTPS. The
  1578. :class:`~django.middleware.security.SecurityMiddleware` strips leading slashes
  1579. from URL paths, so patterns shouldn't include them, e.g.
  1580. ``SECURE_REDIRECT_EXEMPT = [r'^no-ssl/$', …]``. If
  1581. :setting:`SECURE_SSL_REDIRECT` is ``False``, this setting has no effect.
  1582. .. setting:: SECURE_REFERRER_POLICY
  1583. ``SECURE_REFERRER_POLICY``
  1584. --------------------------
  1585. Default: ``'same-origin'``
  1586. If configured, the :class:`~django.middleware.security.SecurityMiddleware` sets
  1587. the :ref:`referrer-policy` header on all responses that do not already have it
  1588. to the value provided.
  1589. .. versionchanged:: 3.1
  1590. In older versions, the default value is ``None``.
  1591. .. setting:: SECURE_SSL_HOST
  1592. ``SECURE_SSL_HOST``
  1593. -------------------
  1594. Default: ``None``
  1595. If a string (e.g. ``secure.example.com``), all SSL redirects will be directed
  1596. to this host rather than the originally-requested host
  1597. (e.g. ``www.example.com``). If :setting:`SECURE_SSL_REDIRECT` is ``False``, this
  1598. setting has no effect.
  1599. .. setting:: SECURE_SSL_REDIRECT
  1600. ``SECURE_SSL_REDIRECT``
  1601. -----------------------
  1602. Default: ``False``
  1603. If ``True``, the :class:`~django.middleware.security.SecurityMiddleware`
  1604. :ref:`redirects <ssl-redirect>` all non-HTTPS requests to HTTPS (except for
  1605. those URLs matching a regular expression listed in
  1606. :setting:`SECURE_REDIRECT_EXEMPT`).
  1607. .. note::
  1608. If turning this to ``True`` causes infinite redirects, it probably means
  1609. your site is running behind a proxy and can't tell which requests are secure
  1610. and which are not. Your proxy likely sets a header to indicate secure
  1611. requests; you can correct the problem by finding out what that header is and
  1612. configuring the :setting:`SECURE_PROXY_SSL_HEADER` setting accordingly.
  1613. .. setting:: SERIALIZATION_MODULES
  1614. ``SERIALIZATION_MODULES``
  1615. -------------------------
  1616. Default: Not defined
  1617. A dictionary of modules containing serializer definitions (provided as
  1618. strings), keyed by a string identifier for that serialization type. For
  1619. example, to define a YAML serializer, use::
  1620. SERIALIZATION_MODULES = {'yaml': 'path.to.yaml_serializer'}
  1621. .. setting:: SERVER_EMAIL
  1622. ``SERVER_EMAIL``
  1623. ----------------
  1624. Default: ``'root@localhost'``
  1625. The email address that error messages come from, such as those sent to
  1626. :setting:`ADMINS` and :setting:`MANAGERS`.
  1627. .. admonition:: Why are my emails sent from a different address?
  1628. This address is used only for error messages. It is *not* the address that
  1629. regular email messages sent with :meth:`~django.core.mail.send_mail()`
  1630. come from; for that, see :setting:`DEFAULT_FROM_EMAIL`.
  1631. .. setting:: SHORT_DATE_FORMAT
  1632. ``SHORT_DATE_FORMAT``
  1633. ---------------------
  1634. Default: ``'m/d/Y'`` (e.g. ``12/31/2003``)
  1635. An available formatting that can be used for displaying date fields on
  1636. templates. Note that if :setting:`USE_L10N` is set to ``True``, then the
  1637. corresponding locale-dictated format has higher precedence and will be applied.
  1638. See :tfilter:`allowed date format strings <date>`.
  1639. See also :setting:`DATE_FORMAT` and :setting:`SHORT_DATETIME_FORMAT`.
  1640. .. setting:: SHORT_DATETIME_FORMAT
  1641. ``SHORT_DATETIME_FORMAT``
  1642. -------------------------
  1643. Default: ``'m/d/Y P'`` (e.g. ``12/31/2003 4 p.m.``)
  1644. An available formatting that can be used for displaying datetime fields on
  1645. templates. Note that if :setting:`USE_L10N` is set to ``True``, then the
  1646. corresponding locale-dictated format has higher precedence and will be applied.
  1647. See :tfilter:`allowed date format strings <date>`.
  1648. See also :setting:`DATE_FORMAT` and :setting:`SHORT_DATE_FORMAT`.
  1649. .. setting:: SIGNING_BACKEND
  1650. ``SIGNING_BACKEND``
  1651. -------------------
  1652. Default: ``'django.core.signing.TimestampSigner'``
  1653. The backend used for signing cookies and other data.
  1654. See also the :doc:`/topics/signing` documentation.
  1655. .. setting:: SILENCED_SYSTEM_CHECKS
  1656. ``SILENCED_SYSTEM_CHECKS``
  1657. --------------------------
  1658. Default: ``[]`` (Empty list)
  1659. A list of identifiers of messages generated by the system check framework
  1660. (i.e. ``["models.W001"]``) that you wish to permanently acknowledge and ignore.
  1661. Silenced checks will not be output to the console.
  1662. See also the :doc:`/ref/checks` documentation.
  1663. .. setting:: TEMPLATES
  1664. ``TEMPLATES``
  1665. -------------
  1666. Default: ``[]`` (Empty list)
  1667. A list containing the settings for all template engines to be used with
  1668. Django. Each item of the list is a dictionary containing the options for an
  1669. individual engine.
  1670. Here's a setup that tells the Django template engine to load templates from the
  1671. ``templates`` subdirectory inside each installed application::
  1672. TEMPLATES = [
  1673. {
  1674. 'BACKEND': 'django.template.backends.django.DjangoTemplates',
  1675. 'APP_DIRS': True,
  1676. },
  1677. ]
  1678. The following options are available for all backends.
  1679. .. setting:: TEMPLATES-BACKEND
  1680. ``BACKEND``
  1681. ~~~~~~~~~~~
  1682. Default: Not defined
  1683. The template backend to use. The built-in template backends are:
  1684. * ``'django.template.backends.django.DjangoTemplates'``
  1685. * ``'django.template.backends.jinja2.Jinja2'``
  1686. You can use a template backend that doesn't ship with Django by setting
  1687. ``BACKEND`` to a fully-qualified path (i.e. ``'mypackage.whatever.Backend'``).
  1688. .. setting:: TEMPLATES-NAME
  1689. ``NAME``
  1690. ~~~~~~~~
  1691. Default: see below
  1692. The alias for this particular template engine. It's an identifier that allows
  1693. selecting an engine for rendering. Aliases must be unique across all
  1694. configured template engines.
  1695. It defaults to the name of the module defining the engine class, i.e. the
  1696. next to last piece of :setting:`BACKEND <TEMPLATES-BACKEND>`, when it isn't
  1697. provided. For example if the backend is ``'mypackage.whatever.Backend'`` then
  1698. its default name is ``'whatever'``.
  1699. .. setting:: TEMPLATES-DIRS
  1700. ``DIRS``
  1701. ~~~~~~~~
  1702. Default: ``[]`` (Empty list)
  1703. Directories where the engine should look for template source files, in search
  1704. order.
  1705. .. setting:: TEMPLATES-APP_DIRS
  1706. ``APP_DIRS``
  1707. ~~~~~~~~~~~~
  1708. Default: ``False``
  1709. Whether the engine should look for template source files inside installed
  1710. applications.
  1711. .. note::
  1712. The default :file:`settings.py` file created by :djadmin:`django-admin
  1713. startproject <startproject>` sets ``'APP_DIRS': True``.
  1714. .. setting:: TEMPLATES-OPTIONS
  1715. ``OPTIONS``
  1716. ~~~~~~~~~~~
  1717. Default: ``{}`` (Empty dict)
  1718. Extra parameters to pass to the template backend. Available parameters vary
  1719. depending on the template backend. See
  1720. :class:`~django.template.backends.django.DjangoTemplates` and
  1721. :class:`~django.template.backends.jinja2.Jinja2` for the options of the
  1722. built-in backends.
  1723. .. setting:: TEST_RUNNER
  1724. ``TEST_RUNNER``
  1725. ---------------
  1726. Default: ``'django.test.runner.DiscoverRunner'``
  1727. The name of the class to use for starting the test suite. See
  1728. :ref:`other-testing-frameworks`.
  1729. .. setting:: TEST_NON_SERIALIZED_APPS
  1730. ``TEST_NON_SERIALIZED_APPS``
  1731. ----------------------------
  1732. Default: ``[]`` (Empty list)
  1733. In order to restore the database state between tests for
  1734. ``TransactionTestCase``\s and database backends without transactions, Django
  1735. will :ref:`serialize the contents of all apps <test-case-serialized-rollback>`
  1736. when it starts the test run so it can then reload from that copy before running
  1737. tests that need it.
  1738. This slows down the startup time of the test runner; if you have apps that
  1739. you know don't need this feature, you can add their full names in here (e.g.
  1740. ``'django.contrib.contenttypes'``) to exclude them from this serialization
  1741. process.
  1742. .. setting:: THOUSAND_SEPARATOR
  1743. ``THOUSAND_SEPARATOR``
  1744. ----------------------
  1745. Default: ``','`` (Comma)
  1746. Default thousand separator used when formatting numbers. This setting is
  1747. used only when :setting:`USE_THOUSAND_SEPARATOR` is ``True`` and
  1748. :setting:`NUMBER_GROUPING` is greater than ``0``.
  1749. Note that if :setting:`USE_L10N` is set to ``True``, then the locale-dictated
  1750. format has higher precedence and will be applied instead.
  1751. See also :setting:`NUMBER_GROUPING`, :setting:`DECIMAL_SEPARATOR` and
  1752. :setting:`USE_THOUSAND_SEPARATOR`.
  1753. .. setting:: TIME_FORMAT
  1754. ``TIME_FORMAT``
  1755. ---------------
  1756. Default: ``'P'`` (e.g. ``4 p.m.``)
  1757. The default formatting to use for displaying time fields in any part of the
  1758. system. Note that if :setting:`USE_L10N` is set to ``True``, then the
  1759. locale-dictated format has higher precedence and will be applied instead. See
  1760. :tfilter:`allowed date format strings <date>`.
  1761. See also :setting:`DATE_FORMAT` and :setting:`DATETIME_FORMAT`.
  1762. .. setting:: TIME_INPUT_FORMATS
  1763. ``TIME_INPUT_FORMATS``
  1764. ----------------------
  1765. Default::
  1766. [
  1767. '%H:%M:%S', # '14:30:59'
  1768. '%H:%M:%S.%f', # '14:30:59.000200'
  1769. '%H:%M', # '14:30'
  1770. ]
  1771. A list of formats that will be accepted when inputting data on a time field.
  1772. Formats will be tried in order, using the first valid one. Note that these
  1773. format strings use Python's :ref:`datetime module syntax
  1774. <strftime-strptime-behavior>`, not the format strings from the :tfilter:`date`
  1775. template filter.
  1776. When :setting:`USE_L10N` is ``True``, the locale-dictated format has higher
  1777. precedence and will be applied instead.
  1778. See also :setting:`DATE_INPUT_FORMATS` and :setting:`DATETIME_INPUT_FORMATS`.
  1779. .. setting:: TIME_ZONE
  1780. ``TIME_ZONE``
  1781. -------------
  1782. Default: ``'America/Chicago'``
  1783. A string representing the time zone for this installation. See the `list of
  1784. time zones`_.
  1785. .. note::
  1786. Since Django was first released with the :setting:`TIME_ZONE` set to
  1787. ``'America/Chicago'``, the global setting (used if nothing is defined in
  1788. your project's ``settings.py``) remains ``'America/Chicago'`` for backwards
  1789. compatibility. New project templates default to ``'UTC'``.
  1790. Note that this isn't necessarily the time zone of the server. For example, one
  1791. server may serve multiple Django-powered sites, each with a separate time zone
  1792. setting.
  1793. When :setting:`USE_TZ` is ``False``, this is the time zone in which Django
  1794. will store all datetimes. When :setting:`USE_TZ` is ``True``, this is the
  1795. default time zone that Django will use to display datetimes in templates and
  1796. to interpret datetimes entered in forms.
  1797. On Unix environments (where :func:`time.tzset` is implemented), Django sets the
  1798. ``os.environ['TZ']`` variable to the time zone you specify in the
  1799. :setting:`TIME_ZONE` setting. Thus, all your views and models will
  1800. automatically operate in this time zone. However, Django won't set the ``TZ``
  1801. environment variable if you're using the manual configuration option as
  1802. described in :ref:`manually configuring settings
  1803. <settings-without-django-settings-module>`. If Django doesn't set the ``TZ``
  1804. environment variable, it's up to you to ensure your processes are running in
  1805. the correct environment.
  1806. .. note::
  1807. Django cannot reliably use alternate time zones in a Windows environment.
  1808. If you're running Django on Windows, :setting:`TIME_ZONE` must be set to
  1809. match the system time zone.
  1810. .. _list of time zones: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
  1811. .. setting:: USE_I18N
  1812. ``USE_I18N``
  1813. ------------
  1814. Default: ``True``
  1815. A boolean that specifies whether Django's translation system should be enabled.
  1816. This provides a way to turn it off, for performance. If this is set to
  1817. ``False``, Django will make some optimizations so as not to load the
  1818. translation machinery.
  1819. See also :setting:`LANGUAGE_CODE`, :setting:`USE_L10N` and :setting:`USE_TZ`.
  1820. .. note::
  1821. The default :file:`settings.py` file created by :djadmin:`django-admin
  1822. startproject <startproject>` includes ``USE_I18N = True`` for convenience.
  1823. .. setting:: USE_L10N
  1824. ``USE_L10N``
  1825. ------------
  1826. Default: ``False``
  1827. A boolean that specifies if localized formatting of data will be enabled by
  1828. default or not. If this is set to ``True``, e.g. Django will display numbers and
  1829. dates using the format of the current locale.
  1830. See also :setting:`LANGUAGE_CODE`, :setting:`USE_I18N` and :setting:`USE_TZ`.
  1831. .. note::
  1832. The default :file:`settings.py` file created by :djadmin:`django-admin
  1833. startproject <startproject>` includes ``USE_L10N = True`` for convenience.
  1834. .. setting:: USE_THOUSAND_SEPARATOR
  1835. ``USE_THOUSAND_SEPARATOR``
  1836. --------------------------
  1837. Default: ``False``
  1838. A boolean that specifies whether to display numbers using a thousand separator.
  1839. When :setting:`USE_L10N` is set to ``True`` and if this is also set to
  1840. ``True``, Django will use the values of :setting:`THOUSAND_SEPARATOR` and
  1841. :setting:`NUMBER_GROUPING` to format numbers unless the locale already has an
  1842. existing thousands separator. If there is a thousands separator in the locale
  1843. format, it will have higher precedence and will be applied instead.
  1844. See also :setting:`DECIMAL_SEPARATOR`, :setting:`NUMBER_GROUPING` and
  1845. :setting:`THOUSAND_SEPARATOR`.
  1846. .. setting:: USE_TZ
  1847. ``USE_TZ``
  1848. ----------
  1849. Default: ``False``
  1850. A boolean that specifies if datetimes will be timezone-aware by default or not.
  1851. If this is set to ``True``, Django will use timezone-aware datetimes internally.
  1852. Otherwise, Django will use naive datetimes in local time.
  1853. See also :setting:`TIME_ZONE`, :setting:`USE_I18N` and :setting:`USE_L10N`.
  1854. .. note::
  1855. The default :file:`settings.py` file created by
  1856. :djadmin:`django-admin startproject <startproject>` includes
  1857. ``USE_TZ = True`` for convenience.
  1858. .. setting:: USE_X_FORWARDED_HOST
  1859. ``USE_X_FORWARDED_HOST``
  1860. ------------------------
  1861. Default: ``False``
  1862. A boolean that specifies whether to use the ``X-Forwarded-Host`` header in
  1863. preference to the ``Host`` header. This should only be enabled if a proxy
  1864. which sets this header is in use.
  1865. This setting takes priority over :setting:`USE_X_FORWARDED_PORT`. Per
  1866. :rfc:`7239#section-5.3`, the ``X-Forwarded-Host`` header can include the port
  1867. number, in which case you shouldn't use :setting:`USE_X_FORWARDED_PORT`.
  1868. .. setting:: USE_X_FORWARDED_PORT
  1869. ``USE_X_FORWARDED_PORT``
  1870. ------------------------
  1871. Default: ``False``
  1872. A boolean that specifies whether to use the ``X-Forwarded-Port`` header in
  1873. preference to the ``SERVER_PORT`` ``META`` variable. This should only be
  1874. enabled if a proxy which sets this header is in use.
  1875. :setting:`USE_X_FORWARDED_HOST` takes priority over this setting.
  1876. .. setting:: WSGI_APPLICATION
  1877. ``WSGI_APPLICATION``
  1878. --------------------
  1879. Default: ``None``
  1880. The full Python path of the WSGI application object that Django's built-in
  1881. servers (e.g. :djadmin:`runserver`) will use. The :djadmin:`django-admin
  1882. startproject <startproject>` management command will create a standard
  1883. ``wsgi.py`` file with an ``application`` callable in it, and point this setting
  1884. to that ``application``.
  1885. If not set, the return value of ``django.core.wsgi.get_wsgi_application()``
  1886. will be used. In this case, the behavior of :djadmin:`runserver` will be
  1887. identical to previous Django versions.
  1888. .. setting:: YEAR_MONTH_FORMAT
  1889. ``YEAR_MONTH_FORMAT``
  1890. ---------------------
  1891. Default: ``'F Y'``
  1892. The default formatting to use for date fields on Django admin change-list
  1893. pages -- and, possibly, by other parts of the system -- in cases when only the
  1894. year and month are displayed.
  1895. For example, when a Django admin change-list page is being filtered by a date
  1896. drilldown, the header for a given month displays the month and the year.
  1897. Different locales have different formats. For example, U.S. English would say
  1898. "January 2006," whereas another locale might say "2006/January."
  1899. Note that if :setting:`USE_L10N` is set to ``True``, then the corresponding
  1900. locale-dictated format has higher precedence and will be applied.
  1901. See :tfilter:`allowed date format strings <date>`. See also
  1902. :setting:`DATE_FORMAT`, :setting:`DATETIME_FORMAT`, :setting:`TIME_FORMAT`
  1903. and :setting:`MONTH_DAY_FORMAT`.
  1904. .. setting:: X_FRAME_OPTIONS
  1905. ``X_FRAME_OPTIONS``
  1906. -------------------
  1907. Default: ``'DENY'``
  1908. The default value for the X-Frame-Options header used by
  1909. :class:`~django.middleware.clickjacking.XFrameOptionsMiddleware`. See the
  1910. :doc:`clickjacking protection </ref/clickjacking/>` documentation.
  1911. Auth
  1912. ====
  1913. Settings for :mod:`django.contrib.auth`.
  1914. .. setting:: AUTHENTICATION_BACKENDS
  1915. ``AUTHENTICATION_BACKENDS``
  1916. ---------------------------
  1917. Default: ``['django.contrib.auth.backends.ModelBackend']``
  1918. A list of authentication backend classes (as strings) to use when attempting to
  1919. authenticate a user. See the :ref:`authentication backends documentation
  1920. <authentication-backends>` for details.
  1921. .. setting:: AUTH_USER_MODEL
  1922. ``AUTH_USER_MODEL``
  1923. -------------------
  1924. Default: ``'auth.User'``
  1925. The model to use to represent a User. See :ref:`auth-custom-user`.
  1926. .. warning::
  1927. You cannot change the AUTH_USER_MODEL setting during the lifetime of
  1928. a project (i.e. once you have made and migrated models that depend on it)
  1929. without serious effort. It is intended to be set at the project start,
  1930. and the model it refers to must be available in the first migration of
  1931. the app that it lives in.
  1932. See :ref:`auth-custom-user` for more details.
  1933. .. setting:: LOGIN_REDIRECT_URL
  1934. ``LOGIN_REDIRECT_URL``
  1935. ----------------------
  1936. Default: ``'/accounts/profile/'``
  1937. The URL or :ref:`named URL pattern <naming-url-patterns>` where requests are
  1938. redirected after login when the :class:`~django.contrib.auth.views.LoginView`
  1939. doesn't get a ``next`` GET parameter.
  1940. .. setting:: LOGIN_URL
  1941. ``LOGIN_URL``
  1942. -------------
  1943. Default: ``'/accounts/login/'``
  1944. The URL or :ref:`named URL pattern <naming-url-patterns>` where requests are
  1945. redirected for login when using the
  1946. :func:`~django.contrib.auth.decorators.login_required` decorator,
  1947. :class:`~django.contrib.auth.mixins.LoginRequiredMixin`, or
  1948. :class:`~django.contrib.auth.mixins.AccessMixin`.
  1949. .. setting:: LOGOUT_REDIRECT_URL
  1950. ``LOGOUT_REDIRECT_URL``
  1951. -----------------------
  1952. Default: ``None``
  1953. The URL or :ref:`named URL pattern <naming-url-patterns>` where requests are
  1954. redirected after logout if :class:`~django.contrib.auth.views.LogoutView`
  1955. doesn't have a ``next_page`` attribute.
  1956. If ``None``, no redirect will be performed and the logout view will be
  1957. rendered.
  1958. .. setting:: PASSWORD_RESET_TIMEOUT
  1959. ``PASSWORD_RESET_TIMEOUT``
  1960. --------------------------
  1961. .. versionadded:: 3.1
  1962. Default: ``259200`` (3 days, in seconds)
  1963. The number of seconds a password reset link is valid for.
  1964. Used by the :class:`~django.contrib.auth.views.PasswordResetConfirmView`.
  1965. .. note::
  1966. Reducing the value of this timeout doesn't make any difference to the
  1967. ability of an attacker to brute-force a password reset token. Tokens are
  1968. designed to be safe from brute-forcing without any timeout.
  1969. This timeout exists to protect against some unlikely attack scenarios, such
  1970. as someone gaining access to email archives that may contain old, unused
  1971. password reset tokens.
  1972. .. setting:: PASSWORD_RESET_TIMEOUT_DAYS
  1973. ``PASSWORD_RESET_TIMEOUT_DAYS``
  1974. -------------------------------
  1975. Default: ``3``
  1976. The number of days a password reset link is valid for.
  1977. Used by the :class:`~django.contrib.auth.views.PasswordResetConfirmView`.
  1978. .. deprecated:: 3.1
  1979. This setting is deprecated. Use :setting:`PASSWORD_RESET_TIMEOUT` instead.
  1980. .. setting:: PASSWORD_HASHERS
  1981. ``PASSWORD_HASHERS``
  1982. --------------------
  1983. See :ref:`auth_password_storage`.
  1984. Default::
  1985. [
  1986. 'django.contrib.auth.hashers.PBKDF2PasswordHasher',
  1987. 'django.contrib.auth.hashers.PBKDF2SHA1PasswordHasher',
  1988. 'django.contrib.auth.hashers.Argon2PasswordHasher',
  1989. 'django.contrib.auth.hashers.BCryptSHA256PasswordHasher',
  1990. ]
  1991. .. setting:: AUTH_PASSWORD_VALIDATORS
  1992. ``AUTH_PASSWORD_VALIDATORS``
  1993. ----------------------------
  1994. Default: ``[]`` (Empty list)
  1995. The list of validators that are used to check the strength of user's passwords.
  1996. See :ref:`password-validation` for more details. By default, no validation is
  1997. performed and all passwords are accepted.
  1998. .. _settings-messages:
  1999. Messages
  2000. ========
  2001. Settings for :mod:`django.contrib.messages`.
  2002. .. setting:: MESSAGE_LEVEL
  2003. ``MESSAGE_LEVEL``
  2004. -----------------
  2005. Default: ``messages.INFO``
  2006. Sets the minimum message level that will be recorded by the messages
  2007. framework. See :ref:`message levels <message-level>` for more details.
  2008. .. admonition:: Important
  2009. If you override ``MESSAGE_LEVEL`` in your settings file and rely on any of
  2010. the built-in constants, you must import the constants module directly to
  2011. avoid the potential for circular imports, e.g.::
  2012. from django.contrib.messages import constants as message_constants
  2013. MESSAGE_LEVEL = message_constants.DEBUG
  2014. If desired, you may specify the numeric values for the constants directly
  2015. according to the values in the above :ref:`constants table
  2016. <message-level-constants>`.
  2017. .. setting:: MESSAGE_STORAGE
  2018. ``MESSAGE_STORAGE``
  2019. -------------------
  2020. Default: ``'django.contrib.messages.storage.fallback.FallbackStorage'``
  2021. Controls where Django stores message data. Valid values are:
  2022. * ``'django.contrib.messages.storage.fallback.FallbackStorage'``
  2023. * ``'django.contrib.messages.storage.session.SessionStorage'``
  2024. * ``'django.contrib.messages.storage.cookie.CookieStorage'``
  2025. See :ref:`message storage backends <message-storage-backends>` for more details.
  2026. The backends that use cookies --
  2027. :class:`~django.contrib.messages.storage.cookie.CookieStorage` and
  2028. :class:`~django.contrib.messages.storage.fallback.FallbackStorage` --
  2029. use the value of :setting:`SESSION_COOKIE_DOMAIN`, :setting:`SESSION_COOKIE_SECURE`
  2030. and :setting:`SESSION_COOKIE_HTTPONLY` when setting their cookies.
  2031. .. setting:: MESSAGE_TAGS
  2032. ``MESSAGE_TAGS``
  2033. ----------------
  2034. Default::
  2035. {
  2036. messages.DEBUG: 'debug',
  2037. messages.INFO: 'info',
  2038. messages.SUCCESS: 'success',
  2039. messages.WARNING: 'warning',
  2040. messages.ERROR: 'error',
  2041. }
  2042. This sets the mapping of message level to message tag, which is typically
  2043. rendered as a CSS class in HTML. If you specify a value, it will extend
  2044. the default. This means you only have to specify those values which you need
  2045. to override. See :ref:`message-displaying` above for more details.
  2046. .. admonition:: Important
  2047. If you override ``MESSAGE_TAGS`` in your settings file and rely on any of
  2048. the built-in constants, you must import the ``constants`` module directly to
  2049. avoid the potential for circular imports, e.g.::
  2050. from django.contrib.messages import constants as message_constants
  2051. MESSAGE_TAGS = {message_constants.INFO: ''}
  2052. If desired, you may specify the numeric values for the constants directly
  2053. according to the values in the above :ref:`constants table
  2054. <message-level-constants>`.
  2055. .. _settings-sessions:
  2056. Sessions
  2057. ========
  2058. Settings for :mod:`django.contrib.sessions`.
  2059. .. setting:: SESSION_CACHE_ALIAS
  2060. ``SESSION_CACHE_ALIAS``
  2061. -----------------------
  2062. Default: ``'default'``
  2063. If you're using :ref:`cache-based session storage <cached-sessions-backend>`,
  2064. this selects the cache to use.
  2065. .. setting:: SESSION_COOKIE_AGE
  2066. ``SESSION_COOKIE_AGE``
  2067. ----------------------
  2068. Default: ``1209600`` (2 weeks, in seconds)
  2069. The age of session cookies, in seconds.
  2070. .. setting:: SESSION_COOKIE_DOMAIN
  2071. ``SESSION_COOKIE_DOMAIN``
  2072. -------------------------
  2073. Default: ``None``
  2074. The domain to use for session cookies. Set this to a string such as
  2075. ``"example.com"`` for cross-domain cookies, or use ``None`` for a standard
  2076. domain cookie.
  2077. Be cautious when updating this setting on a production site. If you update
  2078. this setting to enable cross-domain cookies on a site that previously used
  2079. standard domain cookies, existing user cookies will be set to the old
  2080. domain. This may result in them being unable to log in as long as these cookies
  2081. persist.
  2082. This setting also affects cookies set by :mod:`django.contrib.messages`.
  2083. .. setting:: SESSION_COOKIE_HTTPONLY
  2084. ``SESSION_COOKIE_HTTPONLY``
  2085. ---------------------------
  2086. Default: ``True``
  2087. Whether to use ``HttpOnly`` flag on the session cookie. If this is set to
  2088. ``True``, client-side JavaScript will not be able to access the session
  2089. cookie.
  2090. HttpOnly_ is a flag included in a Set-Cookie HTTP response header. It's part of
  2091. the :rfc:`6265#section-4.1.2.6` standard for cookies and can be a useful way to
  2092. mitigate the risk of a client-side script accessing the protected cookie data.
  2093. This makes it less trivial for an attacker to escalate a cross-site scripting
  2094. vulnerability into full hijacking of a user's session. There aren't many good
  2095. reasons for turning this off. Your code shouldn't read session cookies from
  2096. JavaScript.
  2097. .. _HttpOnly: https://www.owasp.org/index.php/HttpOnly
  2098. .. setting:: SESSION_COOKIE_NAME
  2099. ``SESSION_COOKIE_NAME``
  2100. -----------------------
  2101. Default: ``'sessionid'``
  2102. The name of the cookie to use for sessions. This can be whatever you want
  2103. (as long as it's different from the other cookie names in your application).
  2104. .. setting:: SESSION_COOKIE_PATH
  2105. ``SESSION_COOKIE_PATH``
  2106. -----------------------
  2107. Default: ``'/'``
  2108. The path set on the session cookie. This should either match the URL path of your
  2109. Django installation or be parent of that path.
  2110. This is useful if you have multiple Django instances running under the same
  2111. hostname. They can use different cookie paths, and each instance will only see
  2112. its own session cookie.
  2113. .. setting:: SESSION_COOKIE_SAMESITE
  2114. ``SESSION_COOKIE_SAMESITE``
  2115. ---------------------------
  2116. Default: ``'Lax'``
  2117. The value of the `SameSite`_ flag on the session cookie. This flag prevents the
  2118. cookie from being sent in cross-site requests thus preventing CSRF attacks and
  2119. making some methods of stealing session cookie impossible.
  2120. Possible values for the setting are:
  2121. * ``'Strict'``: prevents the cookie from being sent by the browser to the
  2122. target site in all cross-site browsing context, even when following a regular
  2123. link.
  2124. For example, for a GitHub-like website this would mean that if a logged-in
  2125. user follows a link to a private GitHub project posted on a corporate
  2126. discussion forum or email, GitHub will not receive the session cookie and the
  2127. user won't be able to access the project. A bank website, however, most
  2128. likely doesn't want to allow any transactional pages to be linked from
  2129. external sites so the ``'Strict'`` flag would be appropriate.
  2130. * ``'Lax'`` (default): provides a balance between security and usability for
  2131. websites that want to maintain user's logged-in session after the user
  2132. arrives from an external link.
  2133. In the GitHub scenario, the session cookie would be allowed when following a
  2134. regular link from an external website and be blocked in CSRF-prone request
  2135. methods (e.g. ``POST``).
  2136. * ``'None'`` (string): the session cookie will be sent with all same-site and
  2137. cross-site requests.
  2138. * ``False``: disables the flag.
  2139. .. versionchanged:: 3.1
  2140. Setting ``SESSION_COOKIE_SAMESITE = 'None'`` was allowed.
  2141. .. _SameSite: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
  2142. .. setting:: SESSION_COOKIE_SECURE
  2143. ``SESSION_COOKIE_SECURE``
  2144. -------------------------
  2145. Default: ``False``
  2146. Whether to use a secure cookie for the session cookie. If this is set to
  2147. ``True``, the cookie will be marked as "secure", which means browsers may
  2148. ensure that the cookie is only sent under an HTTPS connection.
  2149. Leaving this setting off isn't a good idea because an attacker could capture an
  2150. unencrypted session cookie with a packet sniffer and use the cookie to hijack
  2151. the user's session.
  2152. .. setting:: SESSION_ENGINE
  2153. ``SESSION_ENGINE``
  2154. ------------------
  2155. Default: ``'django.contrib.sessions.backends.db'``
  2156. Controls where Django stores session data. Included engines are:
  2157. * ``'django.contrib.sessions.backends.db'``
  2158. * ``'django.contrib.sessions.backends.file'``
  2159. * ``'django.contrib.sessions.backends.cache'``
  2160. * ``'django.contrib.sessions.backends.cached_db'``
  2161. * ``'django.contrib.sessions.backends.signed_cookies'``
  2162. See :ref:`configuring-sessions` for more details.
  2163. .. setting:: SESSION_EXPIRE_AT_BROWSER_CLOSE
  2164. ``SESSION_EXPIRE_AT_BROWSER_CLOSE``
  2165. -----------------------------------
  2166. Default: ``False``
  2167. Whether to expire the session when the user closes their browser. See
  2168. :ref:`browser-length-vs-persistent-sessions`.
  2169. .. setting:: SESSION_FILE_PATH
  2170. ``SESSION_FILE_PATH``
  2171. ---------------------
  2172. Default: ``None``
  2173. If you're using file-based session storage, this sets the directory in
  2174. which Django will store session data. When the default value (``None``) is
  2175. used, Django will use the standard temporary directory for the system.
  2176. .. setting:: SESSION_SAVE_EVERY_REQUEST
  2177. ``SESSION_SAVE_EVERY_REQUEST``
  2178. ------------------------------
  2179. Default: ``False``
  2180. Whether to save the session data on every request. If this is ``False``
  2181. (default), then the session data will only be saved if it has been modified --
  2182. that is, if any of its dictionary values have been assigned or deleted. Empty
  2183. sessions won't be created, even if this setting is active.
  2184. .. setting:: SESSION_SERIALIZER
  2185. ``SESSION_SERIALIZER``
  2186. ----------------------
  2187. Default: ``'django.contrib.sessions.serializers.JSONSerializer'``
  2188. Full import path of a serializer class to use for serializing session data.
  2189. Included serializers are:
  2190. * ``'django.contrib.sessions.serializers.PickleSerializer'``
  2191. * ``'django.contrib.sessions.serializers.JSONSerializer'``
  2192. See :ref:`session_serialization` for details, including a warning regarding
  2193. possible remote code execution when using
  2194. :class:`~django.contrib.sessions.serializers.PickleSerializer`.
  2195. Sites
  2196. =====
  2197. Settings for :mod:`django.contrib.sites`.
  2198. .. setting:: SITE_ID
  2199. ``SITE_ID``
  2200. -----------
  2201. Default: Not defined
  2202. The ID, as an integer, of the current site in the ``django_site`` database
  2203. table. This is used so that application data can hook into specific sites
  2204. and a single database can manage content for multiple sites.
  2205. .. _settings-staticfiles:
  2206. Static Files
  2207. ============
  2208. Settings for :mod:`django.contrib.staticfiles`.
  2209. .. setting:: STATIC_ROOT
  2210. ``STATIC_ROOT``
  2211. ---------------
  2212. Default: ``None``
  2213. The absolute path to the directory where :djadmin:`collectstatic` will collect
  2214. static files for deployment.
  2215. Example: ``"/var/www/example.com/static/"``
  2216. If the :doc:`staticfiles</ref/contrib/staticfiles>` contrib app is enabled
  2217. (as in the default project template), the :djadmin:`collectstatic` management
  2218. command will collect static files into this directory. See the how-to on
  2219. :doc:`managing static files</howto/static-files/index>` for more details about
  2220. usage.
  2221. .. warning::
  2222. This should be an initially empty destination directory for collecting
  2223. your static files from their permanent locations into one directory for
  2224. ease of deployment; it is **not** a place to store your static files
  2225. permanently. You should do that in directories that will be found by
  2226. :doc:`staticfiles</ref/contrib/staticfiles>`’s
  2227. :setting:`finders<STATICFILES_FINDERS>`, which by default, are
  2228. ``'static/'`` app sub-directories and any directories you include in
  2229. :setting:`STATICFILES_DIRS`).
  2230. .. setting:: STATIC_URL
  2231. ``STATIC_URL``
  2232. --------------
  2233. Default: ``None``
  2234. URL to use when referring to static files located in :setting:`STATIC_ROOT`.
  2235. Example: ``"/static/"`` or ``"http://static.example.com/"``
  2236. If not ``None``, this will be used as the base path for
  2237. :ref:`asset definitions<form-asset-paths>` (the ``Media`` class) and the
  2238. :doc:`staticfiles app</ref/contrib/staticfiles>`.
  2239. It must end in a slash if set to a non-empty value.
  2240. You may need to :ref:`configure these files to be served in development
  2241. <serving-static-files-in-development>` and will definitely need to do so
  2242. :doc:`in production </howto/static-files/deployment>`.
  2243. .. note::
  2244. If :setting:`STATIC_URL` is a relative path, then it will be prefixed by
  2245. the server-provided value of ``SCRIPT_NAME`` (or ``/`` if not set). This
  2246. makes it easier to serve a Django application in a subpath without adding
  2247. an extra configuration to the settings.
  2248. .. setting:: STATICFILES_DIRS
  2249. ``STATICFILES_DIRS``
  2250. --------------------
  2251. Default: ``[]`` (Empty list)
  2252. This setting defines the additional locations the staticfiles app will traverse
  2253. if the ``FileSystemFinder`` finder is enabled, e.g. if you use the
  2254. :djadmin:`collectstatic` or :djadmin:`findstatic` management command or use the
  2255. static file serving view.
  2256. This should be set to a list of strings that contain full paths to
  2257. your additional files directory(ies) e.g.::
  2258. STATICFILES_DIRS = [
  2259. "/home/special.polls.com/polls/static",
  2260. "/home/polls.com/polls/static",
  2261. "/opt/webfiles/common",
  2262. ]
  2263. Note that these paths should use Unix-style forward slashes, even on Windows
  2264. (e.g. ``"C:/Users/user/mysite/extra_static_content"``).
  2265. .. _staticfiles-dirs-prefixes:
  2266. Prefixes (optional)
  2267. ~~~~~~~~~~~~~~~~~~~
  2268. In case you want to refer to files in one of the locations with an additional
  2269. namespace, you can **optionally** provide a prefix as ``(prefix, path)``
  2270. tuples, e.g.::
  2271. STATICFILES_DIRS = [
  2272. # ...
  2273. ("downloads", "/opt/webfiles/stats"),
  2274. ]
  2275. For example, assuming you have :setting:`STATIC_URL` set to ``'/static/'``, the
  2276. :djadmin:`collectstatic` management command would collect the "stats" files
  2277. in a ``'downloads'`` subdirectory of :setting:`STATIC_ROOT`.
  2278. This would allow you to refer to the local file
  2279. ``'/opt/webfiles/stats/polls_20101022.tar.gz'`` with
  2280. ``'/static/downloads/polls_20101022.tar.gz'`` in your templates, e.g.:
  2281. .. code-block:: html+django
  2282. <a href="{% static "downloads/polls_20101022.tar.gz" %}">
  2283. .. setting:: STATICFILES_STORAGE
  2284. ``STATICFILES_STORAGE``
  2285. -----------------------
  2286. Default: ``'django.contrib.staticfiles.storage.StaticFilesStorage'``
  2287. The file storage engine to use when collecting static files with the
  2288. :djadmin:`collectstatic` management command.
  2289. A ready-to-use instance of the storage backend defined in this setting
  2290. can be found at ``django.contrib.staticfiles.storage.staticfiles_storage``.
  2291. For an example, see :ref:`staticfiles-from-cdn`.
  2292. .. setting:: STATICFILES_FINDERS
  2293. ``STATICFILES_FINDERS``
  2294. -----------------------
  2295. Default::
  2296. [
  2297. 'django.contrib.staticfiles.finders.FileSystemFinder',
  2298. 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  2299. ]
  2300. The list of finder backends that know how to find static files in
  2301. various locations.
  2302. The default will find files stored in the :setting:`STATICFILES_DIRS` setting
  2303. (using ``django.contrib.staticfiles.finders.FileSystemFinder``) and in a
  2304. ``static`` subdirectory of each app (using
  2305. ``django.contrib.staticfiles.finders.AppDirectoriesFinder``). If multiple
  2306. files with the same name are present, the first file that is found will be
  2307. used.
  2308. One finder is disabled by default:
  2309. ``django.contrib.staticfiles.finders.DefaultStorageFinder``. If added to
  2310. your :setting:`STATICFILES_FINDERS` setting, it will look for static files in
  2311. the default file storage as defined by the :setting:`DEFAULT_FILE_STORAGE`
  2312. setting.
  2313. .. note::
  2314. When using the ``AppDirectoriesFinder`` finder, make sure your apps
  2315. can be found by staticfiles by adding the app to the
  2316. :setting:`INSTALLED_APPS` setting of your site.
  2317. Static file finders are currently considered a private interface, and this
  2318. interface is thus undocumented.
  2319. Core Settings Topical Index
  2320. ===========================
  2321. Cache
  2322. -----
  2323. * :setting:`CACHES`
  2324. * :setting:`CACHE_MIDDLEWARE_ALIAS`
  2325. * :setting:`CACHE_MIDDLEWARE_KEY_PREFIX`
  2326. * :setting:`CACHE_MIDDLEWARE_SECONDS`
  2327. Database
  2328. --------
  2329. * :setting:`DATABASES`
  2330. * :setting:`DATABASE_ROUTERS`
  2331. * :setting:`DEFAULT_INDEX_TABLESPACE`
  2332. * :setting:`DEFAULT_TABLESPACE`
  2333. Debugging
  2334. ---------
  2335. * :setting:`DEBUG`
  2336. * :setting:`DEBUG_PROPAGATE_EXCEPTIONS`
  2337. Email
  2338. -----
  2339. * :setting:`ADMINS`
  2340. * :setting:`DEFAULT_CHARSET`
  2341. * :setting:`DEFAULT_FROM_EMAIL`
  2342. * :setting:`EMAIL_BACKEND`
  2343. * :setting:`EMAIL_FILE_PATH`
  2344. * :setting:`EMAIL_HOST`
  2345. * :setting:`EMAIL_HOST_PASSWORD`
  2346. * :setting:`EMAIL_HOST_USER`
  2347. * :setting:`EMAIL_PORT`
  2348. * :setting:`EMAIL_SSL_CERTFILE`
  2349. * :setting:`EMAIL_SSL_KEYFILE`
  2350. * :setting:`EMAIL_SUBJECT_PREFIX`
  2351. * :setting:`EMAIL_TIMEOUT`
  2352. * :setting:`EMAIL_USE_LOCALTIME`
  2353. * :setting:`EMAIL_USE_TLS`
  2354. * :setting:`MANAGERS`
  2355. * :setting:`SERVER_EMAIL`
  2356. Error reporting
  2357. ---------------
  2358. * :setting:`DEFAULT_EXCEPTION_REPORTER`
  2359. * :setting:`DEFAULT_EXCEPTION_REPORTER_FILTER`
  2360. * :setting:`IGNORABLE_404_URLS`
  2361. * :setting:`MANAGERS`
  2362. * :setting:`SILENCED_SYSTEM_CHECKS`
  2363. .. _file-upload-settings:
  2364. File uploads
  2365. ------------
  2366. * :setting:`DEFAULT_FILE_STORAGE`
  2367. * :setting:`FILE_UPLOAD_HANDLERS`
  2368. * :setting:`FILE_UPLOAD_MAX_MEMORY_SIZE`
  2369. * :setting:`FILE_UPLOAD_PERMISSIONS`
  2370. * :setting:`FILE_UPLOAD_TEMP_DIR`
  2371. * :setting:`MEDIA_ROOT`
  2372. * :setting:`MEDIA_URL`
  2373. Forms
  2374. -----
  2375. * :setting:`FORM_RENDERER`
  2376. Globalization (``i18n``/``l10n``)
  2377. ---------------------------------
  2378. * :setting:`DATE_FORMAT`
  2379. * :setting:`DATE_INPUT_FORMATS`
  2380. * :setting:`DATETIME_FORMAT`
  2381. * :setting:`DATETIME_INPUT_FORMATS`
  2382. * :setting:`DECIMAL_SEPARATOR`
  2383. * :setting:`FIRST_DAY_OF_WEEK`
  2384. * :setting:`FORMAT_MODULE_PATH`
  2385. * :setting:`LANGUAGE_CODE`
  2386. * :setting:`LANGUAGE_COOKIE_AGE`
  2387. * :setting:`LANGUAGE_COOKIE_DOMAIN`
  2388. * :setting:`LANGUAGE_COOKIE_HTTPONLY`
  2389. * :setting:`LANGUAGE_COOKIE_NAME`
  2390. * :setting:`LANGUAGE_COOKIE_PATH`
  2391. * :setting:`LANGUAGE_COOKIE_SAMESITE`
  2392. * :setting:`LANGUAGE_COOKIE_SECURE`
  2393. * :setting:`LANGUAGES`
  2394. * :setting:`LANGUAGES_BIDI`
  2395. * :setting:`LOCALE_PATHS`
  2396. * :setting:`MONTH_DAY_FORMAT`
  2397. * :setting:`NUMBER_GROUPING`
  2398. * :setting:`SHORT_DATE_FORMAT`
  2399. * :setting:`SHORT_DATETIME_FORMAT`
  2400. * :setting:`THOUSAND_SEPARATOR`
  2401. * :setting:`TIME_FORMAT`
  2402. * :setting:`TIME_INPUT_FORMATS`
  2403. * :setting:`TIME_ZONE`
  2404. * :setting:`USE_I18N`
  2405. * :setting:`USE_L10N`
  2406. * :setting:`USE_THOUSAND_SEPARATOR`
  2407. * :setting:`USE_TZ`
  2408. * :setting:`YEAR_MONTH_FORMAT`
  2409. HTTP
  2410. ----
  2411. * :setting:`DATA_UPLOAD_MAX_MEMORY_SIZE`
  2412. * :setting:`DATA_UPLOAD_MAX_NUMBER_FIELDS`
  2413. * :setting:`DEFAULT_CHARSET`
  2414. * :setting:`DISALLOWED_USER_AGENTS`
  2415. * :setting:`FORCE_SCRIPT_NAME`
  2416. * :setting:`INTERNAL_IPS`
  2417. * :setting:`MIDDLEWARE`
  2418. * Security
  2419. * :setting:`SECURE_BROWSER_XSS_FILTER`
  2420. * :setting:`SECURE_CONTENT_TYPE_NOSNIFF`
  2421. * :setting:`SECURE_HSTS_INCLUDE_SUBDOMAINS`
  2422. * :setting:`SECURE_HSTS_PRELOAD`
  2423. * :setting:`SECURE_HSTS_SECONDS`
  2424. * :setting:`SECURE_PROXY_SSL_HEADER`
  2425. * :setting:`SECURE_REDIRECT_EXEMPT`
  2426. * :setting:`SECURE_REFERRER_POLICY`
  2427. * :setting:`SECURE_SSL_HOST`
  2428. * :setting:`SECURE_SSL_REDIRECT`
  2429. * :setting:`SIGNING_BACKEND`
  2430. * :setting:`USE_X_FORWARDED_HOST`
  2431. * :setting:`USE_X_FORWARDED_PORT`
  2432. * :setting:`WSGI_APPLICATION`
  2433. Logging
  2434. -------
  2435. * :setting:`LOGGING`
  2436. * :setting:`LOGGING_CONFIG`
  2437. Models
  2438. ------
  2439. * :setting:`ABSOLUTE_URL_OVERRIDES`
  2440. * :setting:`FIXTURE_DIRS`
  2441. * :setting:`INSTALLED_APPS`
  2442. Security
  2443. --------
  2444. * Cross Site Request Forgery Protection
  2445. * :setting:`CSRF_COOKIE_DOMAIN`
  2446. * :setting:`CSRF_COOKIE_NAME`
  2447. * :setting:`CSRF_COOKIE_PATH`
  2448. * :setting:`CSRF_COOKIE_SAMESITE`
  2449. * :setting:`CSRF_COOKIE_SECURE`
  2450. * :setting:`CSRF_FAILURE_VIEW`
  2451. * :setting:`CSRF_HEADER_NAME`
  2452. * :setting:`CSRF_TRUSTED_ORIGINS`
  2453. * :setting:`CSRF_USE_SESSIONS`
  2454. * :setting:`SECRET_KEY`
  2455. * :setting:`X_FRAME_OPTIONS`
  2456. Serialization
  2457. -------------
  2458. * :setting:`DEFAULT_CHARSET`
  2459. * :setting:`SERIALIZATION_MODULES`
  2460. Templates
  2461. ---------
  2462. * :setting:`TEMPLATES`
  2463. Testing
  2464. -------
  2465. * Database: :setting:`TEST <DATABASE-TEST>`
  2466. * :setting:`TEST_NON_SERIALIZED_APPS`
  2467. * :setting:`TEST_RUNNER`
  2468. URLs
  2469. ----
  2470. * :setting:`APPEND_SLASH`
  2471. * :setting:`PREPEND_WWW`
  2472. * :setting:`ROOT_URLCONF`