settings.txt 103 KB

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