settings.txt 105 KB

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