File tree Expand file tree Collapse file tree 4 files changed +49
-4
lines changed Expand file tree Collapse file tree 4 files changed +49
-4
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,22 @@ def ready(self):
2424 # allows panels like CachePanel to enable their instrumentation immediately.
2525 for cls in DebugToolbar .get_panel_classes ():
2626 cls .ready ()
27+ _manage_migrations_visibility (self .name )
28+
29+
30+ def _manage_migrations_visibility (app_name ):
31+ """
32+ Adjust the toolbar's migration visibility by manipulating the
33+ project's settings.
34+
35+ This is a hack since it's manipulating settings.
36+ """
37+ if (
38+ dt_settings .get_config ()["TOOLBAR_STORE_CLASS" ]
39+ != "debug_toolbar.store.DatabaseStore"
40+ ):
41+ # This effectively hides the migrations by telling Django they don't exist.
42+ settings .MIGRATION_MODULES .setdefault (app_name , None )
2743
2844
2945def check_template_config (config ):
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ Pending
1616* Upgraded CI ``postgis `` version to 17-3.5.
1717* Added how to generate the documentation locally to the contributing
1818 documentation.
19+ * Hide the toolbar's migrations unless the database store is being used. This
20+ may change in the future.
1921
20226.0.0 (2025-07-22)
2123------------------
Original file line number Diff line number Diff line change @@ -196,15 +196,15 @@ Toolbar options
196196 The DatabaseStore provides persistence and automatically cleans up old
197197 entries based on the ``RESULTS_CACHE_SIZE `` setting.
198198
199- Note: For full functionality, DatabaseStore requires migrations for
200- the debug_toolbar app:
199+ Note: When using `` DatabaseStore `` migrations are required for
200+ the `` debug_toolbar `` app:
201201
202202 .. code-block :: bash
203203
204204 python manage.py migrate debug_toolbar
205205
206- For the DatabaseStore to work properly, you need to run migrations for the
207- debug_toolbar app. The migrations create the necessary database table to store
206+ For the `` DatabaseStore `` to work properly, you need to run migrations for the
207+ `` debug_toolbar `` app. The migrations create the necessary database table to store
208208 toolbar data.
209209
210210.. _TOOLBAR_LANGUAGE :
Original file line number Diff line number Diff line change 1+ from unittest .mock import patch
2+
3+ from django .test import SimpleTestCase , override_settings
4+
5+ from debug_toolbar .apps import _manage_migrations_visibility
6+
7+
8+ class AppsTestCase (SimpleTestCase ):
9+ @override_settings (
10+ DEBUG_TOOLBAR_CONFIG = {
11+ "TOOLBAR_STORE_CLASS" : "debug_toolbar.store.DatabaseStore"
12+ }
13+ )
14+ @patch ("debug_toolbar.apps.settings.MIGRATION_MODULES" )
15+ def test_migrations_are_visible (self , mocked_migration_modules ):
16+ _manage_migrations_visibility ("debug_toolbar" )
17+ self .assertFalse (mocked_migration_modules .setdefault .called )
18+
19+ @override_settings (
20+ DEBUG_TOOLBAR_CONFIG = {"TOOLBAR_STORE_CLASS" : "debug_toolbar.store.MemoryStore" }
21+ )
22+ @patch ("debug_toolbar.apps.settings.MIGRATION_MODULES" )
23+ def test_migrations_are_hidden (self , mocked_migration_modules ):
24+ _manage_migrations_visibility ("debug_toolbar" )
25+ mocked_migration_modules .setdefault .assert_called_once_with (
26+ "debug_toolbar" , None
27+ )
You can’t perform that action at this time.
0 commit comments