Code

Ticket #19875: 19875.2.diff

File 19875.2.diff, 2.4 KB (added by timo, 14 months ago)
Line 
1diff --git a/django/conf/project_template/project_name/settings.py b/django/conf/project_template/project_name/settings.py
2index efe8091..15d2991 100644
3--- a/django/conf/project_template/project_name/settings.py
4+++ b/django/conf/project_template/project_name/settings.py
5@@ -24,6 +24,7 @@ DEBUG = True
6 
7 TEMPLATE_DEBUG = True
8 
9+# required if DEBUG is False
10 ALLOWED_HOSTS = []
11 
12 
13diff --git a/docs/intro/tutorial03.txt b/docs/intro/tutorial03.txt
14index 1203691..6193ec4 100644
15--- a/docs/intro/tutorial03.txt
16+++ b/docs/intro/tutorial03.txt
17@@ -473,6 +473,13 @@ template for all 404 errors when :setting:`DEBUG` is set to ``False`` (in your
18 settings module). If you do create the template, add at least some dummy
19 content like "Page not found".
20 
21+.. warning::
22+
23+    If :setting:`DEBUG` is set to ``False``, all responses will be
24+    "Bad Request (400)" unless you specify the proper :setting:`ALLOWED_HOSTS`
25+    as well (something like ``['localhost', '127.0.0.1']`` for
26+    local development).
27+
28 A couple more things to note about 404 views:
29 
30 * If :setting:`DEBUG` is set to ``True`` (in your settings module) then your
31diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt
32index b8ebc16..748b2bf 100644
33--- a/docs/ref/settings.txt
34+++ b/docs/ref/settings.txt
35@@ -852,6 +852,10 @@ It is also important to remember that when running with :setting:`DEBUG`
36 turned on, Django will remember every SQL query it executes. This is useful
37 when you're debugging, but it'll rapidly consume memory on a production server.
38 
39+Finally, if :setting:`DEBUG` is ``False``, you also need to properly set
40+the :setting:`ALLOWED_HOSTS` setting. Failing to do so will result in all
41+requests being returned as "Bad Request (400)".
42+
43 .. _django/views/debug.py: https://github.com/django/django/blob/master/django/views/debug.py
44 
45 .. setting:: DEBUG_PROPAGATE_EXCEPTIONS
46diff --git a/docs/topics/settings.txt b/docs/topics/settings.txt
47index fa26297..1cfcd26 100644
48--- a/docs/topics/settings.txt
49+++ b/docs/topics/settings.txt
50@@ -17,6 +17,11 @@ Here are a couple of example settings::
51     DEFAULT_FROM_EMAIL = 'webmaster@example.com'
52     TEMPLATE_DIRS = ('/home/templates/mike', '/home/templates/john')
53 
54+.. note::
55+
56+    If you set :setting:`DEBUG` to ``False``, you also need to properly set
57+    the :setting:`ALLOWED_HOSTS` setting.
58+
59 Because a settings file is a Python module, the following apply:
60 
61 * It doesn't allow for Python syntax errors.