settings.txt 108 KB

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