settings.txt 103 KB

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