settings.txt 93 KB

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