settings.txt 104 KB

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