Skip to content

Commit 22c22d7

Browse files
committed
Documented backwards incompatible change in 1.8
SHOW_TOOLBAR_CALLBACK no longer returns False for AJAX requests. Custom values shouldn't either. Fixes django-commons#954
1 parent 88ddc7b commit 22c22d7

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

docs/changes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ Bugfixes
1515
This version is compatible with Django 1.11 and requires Django 1.8 or
1616
later.
1717

18+
**Backwards incompatible changes**
19+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20+
21+
* ``debug_toolbar.middleware.show_toolbar`` (the default value of setting
22+
``SHOW_TOOLBAR_CALLBACK``) no longer returns ``False`` for AJAX requests.
23+
This is to allow reusing the ``SHOW_TOOLBAR_CALLBACK`` function to verify
24+
access to panel views requested via AJAX. Projects defining a custom
25+
``SHOW_TOOLBAR_CALLBACK`` should remove checks for AJAX requests in order to
26+
continue to allow access to these panels.
27+
1828
Features
1929
~~~~~~~~
2030

docs/configuration.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,15 @@ Toolbar options
112112
Default: 'debug_toolbar.middleware.show_toolbar'
113113

114114
This is the dotted path to a function used for determining whether the
115-
toolbar should show or not. The default checks are that ``DEBUG`` must be
116-
set to ``True``, the IP of the request must be in ``INTERNAL_IPS``, and the
117-
request must not be an AJAX request. You can provide your own function
118-
``callback(request)`` which returns ``True`` or ``False``.
115+
toolbar should show or not. The default checks are that ``DEBUG`` must be set
116+
to ``True`` and the IP of the request must be in ``INTERNAL_IPS``. You can
117+
provide your own function ``callback(request)`` which returns ``True`` or
118+
``False``.
119+
120+
For versions < 1.8, the callback should also return ``False`` for AJAX
121+
requests. Since version 1.8, AJAX requests are checked in the middleware, not
122+
the callback. This allows reusing the callback to verify access to panel
123+
views requested via AJAX.
119124

120125
Panel options
121126
~~~~~~~~~~~~~

0 commit comments

Comments
 (0)