settings.txt 104 KB

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