settings.txt 103 KB

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