1
1
Installation
2
2
============
3
3
4
+ Each of the following steps needs to be configured for the Debug Toolbar to be
5
+ fully functional.
6
+
4
7
Getting the code
5
8
----------------
6
9
@@ -37,8 +40,8 @@ Make sure that ``'django.contrib.staticfiles'`` is `set up properly
37
40
If you're upgrading from a previous version, you should review the
38
41
:doc: `change log <changes >` and look for specific upgrade instructions.
39
42
40
- URLconf
41
- -------
43
+ Setting up URLconf
44
+ ------------------
42
45
43
46
Add the Debug Toolbar's URLs to your project's URLconf as follows::
44
47
@@ -50,18 +53,18 @@ Add the Debug Toolbar's URLs to your project's URLconf as follows::
50
53
import debug_toolbar
51
54
urlpatterns = [
52
55
path('__debug__/', include(debug_toolbar.urls)),
53
-
56
+
54
57
# For django versions before 2.0:
55
58
# url(r'^__debug__/', include(debug_toolbar.urls)),
56
-
59
+
57
60
] + urlpatterns
58
61
59
62
This example uses the ``__debug__ `` prefix, but you can use any prefix that
60
63
doesn't clash with your application's URLs. Note the lack of quotes around
61
64
``debug_toolbar.urls ``.
62
65
63
- Middleware
64
- ----------
66
+ Enabling middleware
67
+ -------------------
65
68
66
69
The Debug Toolbar is mostly implemented in a middleware. Enable it in your
67
70
settings module as follows::
@@ -88,10 +91,21 @@ Old-style middleware::
88
91
response's content, such as
89
92
:class: `~django.middleware.gzip.GZipMiddleware `.
90
93
91
- Internal IPs
92
- ------------
94
+ Configuring Internal IPs
95
+ ------------------------
96
+
97
+ The Debug Toolbar is shown only if your IP address is listed in the
98
+ :django:setting: `INTERNAL_IPS ` setting. This means that for local
99
+ development, you *must * add ``'127.0.0.1' `` to :django:setting: `INTERNAL_IPS `;
100
+ you'll need to create this setting if it doesn't already exist in your
101
+ settings module::
102
+
103
+ INTERNAL_IPS = [
104
+ # ...
105
+ '127.0.0.1',
106
+ # ...
107
+ ]
93
108
94
- The Debug Toolbar is shown only if your IP is listed in the ``INTERNAL_IPS ``
95
- setting. (You can change this logic with the ``SHOW_TOOLBAR_CALLBACK ``
96
- option.) For local development, you should add ``'127.0.0.1' `` to
97
- ``INTERNAL_IPS ``.
109
+ You can change the logic of determining whether or not the Debug Toolbar
110
+ should be shown with the :ref: `SHOW_TOOLBAR_CALLBACK <SHOW_TOOLBAR_CALLBACK >`
111
+ option. This option allows you to specify a custom function for this purpose.
0 commit comments