settings.txt 111 KB

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