settings.txt 103 KB

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