settings.txt 103 KB

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