settings.txt 103 KB

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