settings.txt 89 KB

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