settings.txt 102 KB

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