settings.txt 105 KB

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