Description
The v6.0.0 release of Django Debug Toolbar significantly revamps how panels for the toolbar work. Each panel will now persist its data in a store. A store can either be backed by various backends. The toolbar will support a memory and database backend to start.
The toolbar is now using Django's SafeExceptionReporterFilter.cleanse_setting()
function to filter out sensitive information. Some data will be replaced with "********************"
. This is because the toolbar could be configured to write the request information to a persistent store such as a cache or database.
Django applications with basic installations are backwards compatible with this change. If there are hooks into the internals of the toolbar, such as DebugToolbar.store_id
then it will be backwards incompatible.
Third-party panels will need updating. Any data that is stored in record_stats
will need to be fetched back out from self.get_stats()
before being able to be rendered. This is to support loading an instance of the toolbar from persisted data. A simple example of this transition can be found in debug_toolbar/panels/cache.py
in PR 2138
How to upgrade
- Changes required if the toolbar isn't installed entirely programmatically
- If you experience
RuntimeError: Model class debug_toolbar.models.HistoryEntry doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
, you need to remove the reference to the toolbar's urls in yoururls.py
file andMIDDLEWARE
setting when the toolbar isn't inINSTALLED_APPS
- If you experience
- If you have a custom panel, you'll need to adjust
record_stats
and useself.get_stats()
to fetch data for rendering - If you'd like to use the database store, see
TOOLBAR_STORE_CLASS
for more info
Why did the internals change?
The Django Debug Toolbar is a popular package we did not want to block the community from pursuing the async path for Django applications. Writing the request data to a store better positions the toolbar for async projects. It also opens the door for it being usable in production as well with API integrations.
What's Changed
- Log serialization warning when a panel errors. by @tim-schilling in #1810
- Improve clarity of record_stats for serialization. by @tim-schilling in #1965
- Update serializable branch with main by @tim-schilling in #2072
- Remove pin for django-csp. by @tim-schilling in #2132
- Fixes #2073 -- Added DatabaseStore for persistent debug data storage. by @dr-rompecabezas in #2121
- Disabled document.cookie linter by @tim-schilling in #2139
- Added check for pytest as test runner for IS_RUNNING_TESTS. by @tim-schilling in #2137
- Remove Type Hints from CspRenderingTestCase by @andoriyaprashant in #2144
- Add show_toolbar_with_docker function for Docker IP handling by @matthiask in #2153
- Support serializable toolbar by @tim-schilling in #2138
- Deduplicate staticfiles by @matthiask in #2155
- Fixes #2158 -- Made static file objects orderable by @matthiask in #2161
- Fixes #2160 -- Corrected links to static files by @matthiask in #2162
- Fixes #2151 -- Forwarded args and kwargs in URLMixin.url by @matthiask in #2163
- Fixes #2159 -- Do not HTML-escape traces in the cache and profiling panel by @matthiask in #2164
Full Changelog: 5.2.0...6.0.0
Acknowlegements
Thank you to all the contributors who made this release possible. Thank you to @robhudson, @matthiask, @tim-schilling, @salty-ivy and @dr-rompecabezas for their support, development and reviews of the serializable toolbar changes. A special shout-out to @matthiask for leading the Djangonaut Space Session 4 team of @dr-rompecabezas, @andoriyaprashant and @blingblin-g.