settings.txt 104 KB

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