File tree Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Expand file tree Collapse file tree 3 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,13 @@ def ready(self):
2626 cls .ready ()
2727 _manage_migrations_visibility (self .name )
2828
29+ def import_models (self ):
30+ dt_config = dt_settings .get_config ()
31+ if dt_config ["TOOLBAR_STORE_CLASS" ] == "debug_toolbar.store.DatabaseStore" :
32+ return super ().import_models ()
33+ # Not using the database store, don't import the models
34+ self .models = {}
35+
2936
3037def _manage_migrations_visibility (app_name ):
3138 """
Original file line number Diff line number Diff line change @@ -16,8 +16,11 @@ 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.
19+ * Hide the toolbar's migrations unless ``debug_toolbar.store.DatabaseStore ``
20+ is being used. This may change in the future.
21+ * Hide ``debug_toolbar.HistoryEntry `` as a model unless
22+ ``debug_toolbar.store.DatabaseStore `` is being used. This may change in the
23+ future.
2124
22256.0.0 (2025-07-22)
2326------------------
Original file line number Diff line number Diff line change 11from unittest .mock import patch
22
3+ from django .apps import apps
34from django .test import SimpleTestCase , override_settings
45
56from debug_toolbar .apps import _manage_migrations_visibility
@@ -25,3 +26,22 @@ def test_migrations_are_hidden(self, mocked_migration_modules):
2526 mocked_migration_modules .setdefault .assert_called_once_with (
2627 "debug_toolbar" , None
2728 )
29+
30+ @override_settings (
31+ DEBUG_TOOLBAR_CONFIG = {
32+ "TOOLBAR_STORE_CLASS" : "debug_toolbar.store.DatabaseStore"
33+ }
34+ )
35+ def test_models_are_visible (self ):
36+ app_config = apps .get_app_config ("debug_toolbar" )
37+ app_config .import_models ()
38+ apps .get_model ("debug_toolbar" , "HistoryEntry" )
39+
40+ @override_settings (
41+ DEBUG_TOOLBAR_CONFIG = {"TOOLBAR_STORE_CLASS" : "debug_toolbar.store.MemoryStore" }
42+ )
43+ def test_models_are_hidden (self ):
44+ app_config = apps .get_app_config ("debug_toolbar" )
45+ app_config .import_models ()
46+ with self .assertRaises (LookupError ):
47+ apps .get_model ("debug_toolbar" , "HistoryEntry" )
You can’t perform that action at this time.
0 commit comments