Skip to content

Commit c24a1a2

Browse files
committed
Expand installation documentation
This adds clearer explanations of installing Debug Toolbar, in particularly the process of setting up INTERNAL_IPS, including linking to the relevant documentation in the Django docs and linking to Debug Toolbar's own option in that section.
1 parent 995db40 commit c24a1a2

File tree

3 files changed

+39
-12
lines changed

3 files changed

+39
-12
lines changed

docs/conf.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,14 @@
275275
# -- Options for Read the Docs --------------------------------------------
276276

277277
RTD_NEW_THEME = True
278+
279+
280+
def setup(app):
281+
""" Configure documentation via Sphinx extension
282+
"""
283+
# Add the :setting: role for intersphinx linking to Django's docs
284+
app.add_crossref_type(
285+
directivename="setting",
286+
rolename="setting",
287+
indextemplate="pair: %s; setting",
288+
)

docs/configuration.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ Toolbar options
9999

100100
If changed to ``True``, the toolbar will be collapsed by default.
101101

102+
.. _SHOW_TOOLBAR_CALLBACK:
103+
102104
* ``SHOW_TOOLBAR_CALLBACK``
103105

104106
Default: ``'debug_toolbar.middleware.show_toolbar'``

docs/installation.rst

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Installation
22
============
33

4+
Each of the following steps needs to be configured for the Debug Toolbar to be
5+
fully functional.
6+
47
Getting the code
58
----------------
69

@@ -37,8 +40,8 @@ Make sure that ``'django.contrib.staticfiles'`` is `set up properly
3740
If you're upgrading from a previous version, you should review the
3841
:doc:`change log <changes>` and look for specific upgrade instructions.
3942

40-
URLconf
41-
-------
43+
Setting up URLconf
44+
------------------
4245

4346
Add the Debug Toolbar's URLs to your project's URLconf as follows::
4447

@@ -50,18 +53,18 @@ Add the Debug Toolbar's URLs to your project's URLconf as follows::
5053
import debug_toolbar
5154
urlpatterns = [
5255
path('__debug__/', include(debug_toolbar.urls)),
53-
56+
5457
# For django versions before 2.0:
5558
# url(r'^__debug__/', include(debug_toolbar.urls)),
56-
59+
5760
] + urlpatterns
5861

5962
This example uses the ``__debug__`` prefix, but you can use any prefix that
6063
doesn't clash with your application's URLs. Note the lack of quotes around
6164
``debug_toolbar.urls``.
6265

63-
Middleware
64-
----------
66+
Enabling middleware
67+
-------------------
6568

6669
The Debug Toolbar is mostly implemented in a middleware. Enable it in your
6770
settings module as follows::
@@ -88,10 +91,21 @@ Old-style middleware::
8891
response's content, such as
8992
:class:`~django.middleware.gzip.GZipMiddleware`.
9093

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+
]
93108

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

Comments
 (0)