Skip to content

Commit 8331472

Browse files
committed
Discourage relying on the automatic setup.
1 parent 1fabe70 commit 8331472

File tree

1 file changed

+37
-22
lines changed

1 file changed

+37
-22
lines changed

docs/installation.rst

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ instead with the following command::
1818

1919
$ pip install -e git+https://github.com/django-debug-toolbar/django-debug-toolbar.git#egg=django-debug-toolbar
2020

21-
Quick setup
22-
-----------
21+
Prerequisites
22+
-------------
2323

2424
Make sure that ``'django.contrib.staticfiles'`` is `set up properly
2525
<https://docs.djangoproject.com/en/stable/howto/static-files/>`_ and add
@@ -34,25 +34,35 @@ Make sure that ``'django.contrib.staticfiles'`` is `set up properly
3434

3535
STATIC_URL = '/static/'
3636

37-
For a simple Django project, that's all you need!
38-
39-
The Debug Toolbar will automatically adjust a few settings when you start the
40-
development server, provided the ``DEBUG`` setting is ``True``.
41-
4237
If you're upgrading from a previous version, you should review the
4338
:doc:`change log <changes>` and look for specific upgrade instructions.
4439

45-
If the automatic setup doesn't work for your project, if you want to learn
46-
what it does, or if you prefer defining your settings explicitly, read below.
40+
Automatic setup
41+
---------------
42+
43+
If you just add the Debug Toolbar to the ``INSTALLED_APPS`` setting as shown
44+
above, when the ``DEBUG`` setting is ``True``, the Debug Toolbar will attempt
45+
to patch your settings to configure itself automatically.
4746

4847
.. warning::
4948

49+
The automatic setup is known to interfere with the start-up sequence of
50+
some projects and to prevent them from loading or functioning properly.
51+
52+
**The explicit setup described below is recommended for all but the most
53+
trivial projects. The automatic setup is kept for backwards-compatibility.**
54+
55+
.. note::
56+
5057
The automatic setup imports your project's URLconf in order to add the
51-
Debug Toolbar's URLs. This may trigger circular imports, for instance when
52-
the URLconf imports views that import models. If the development server
53-
crashes with a long stack trace after hitting an :exc:`ImportError` or an
54-
:exc:`~django.core.exceptions.ImproperlyConfigured` exception, follow the
55-
explicit setup instructions.
58+
Debug Toolbar's URLs. This is likely to trigger circular imports, for
59+
instance when the URLconf imports views that import models, a pattern
60+
found in almost every Django project.
61+
62+
If the development server crashes with a long stack trace after hitting an
63+
:exc:`ImportError`, an :exc:`~django.apps.exceptions.AppRegistryNotReady`
64+
or an :exc:`~django.core.exceptions.ImproperlyConfigured` exception, use
65+
the explicit setup described below.
5666

5767
When the automatic setup is used, the Debug Toolbar is not compatible with
5868
:class:`~django.middleware.gzip.GZipMiddleware`. Please disable that
@@ -62,8 +72,8 @@ what it does, or if you prefer defining your settings explicitly, read below.
6272
Explicit setup
6373
--------------
6474

65-
First, tell the toolbar not to adjust your settings automatically by adding
66-
this line in your settings module::
75+
This is the recommended way to configure the Debug Toolbar. First, disable the
76+
automatic setup by adding this line in your settings module::
6777

6878
DEBUG_TOOLBAR_PATCH_SETTINGS = False
6979

@@ -85,8 +95,9 @@ This example uses the ``__debug__`` prefix, but you can use any prefix that
8595
doesn't clash with your application's URLs. Note the lack of quotes around
8696
``debug_toolbar.urls``.
8797

88-
If the URLs aren't included in your root URLconf, the Debug Toolbar
89-
automatically appends them.
98+
.. note::
99+
100+
The automatic setup appends the Debug Toolbar URLs to the root URLconf.
90101

91102
Middleware
92103
~~~~~~~~~~
@@ -105,8 +116,10 @@ Toolbar middleware as early as possible in the list. However, it must come
105116
after any other middleware that encodes the response's content, such as
106117
:class:`~django.middleware.gzip.GZipMiddleware`.
107118

108-
If ``MIDDLEWARE_CLASSES`` doesn't contain the middleware, the Debug Toolbar
109-
automatically adds it the beginning of the list.
119+
.. note::
120+
121+
The automatic setup inserts the Debug Toolbar middleware at the beginning
122+
of ``MIDDLEWARE_CLASSES``, unless it's already included.
110123

111124
Internal IPs
112125
~~~~~~~~~~~~
@@ -116,5 +129,7 @@ setting. (You can change this logic with the ``SHOW_TOOLBAR_CALLBACK``
116129
option.) For local development, you should add ``'127.0.0.1'`` to
117130
``INTERNAL_IPS``.
118131

119-
If ``INTERNAL_IPS`` is empty, the Debug Toolbar automatically sets it to
120-
``'127.0.0.1'`` and ``'::1'``.
132+
.. note::
133+
134+
The automatic setup sets ``INTERNAL_IPS`` to ``'127.0.0.1'`` and
135+
``'::1'``, unless it's already set to a non-empty value.

0 commit comments

Comments
 (0)