Skip to content

Commit 148fa1e

Browse files
authored
Don't check for URLs if ROOT_URLCONF isn't defined (#2342)
1 parent b3f943b commit 148fa1e

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

debug_toolbar/apps.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,17 @@ def debug_toolbar_installed_when_running_tests_check(app_configs, **kwargs):
249249
dt_settings.get_config()["SHOW_TOOLBAR_CALLBACK"]
250250
!= CONFIG_DEFAULTS["SHOW_TOOLBAR_CALLBACK"]
251251
)
252-
try:
253-
# Check if the toolbar's urls are installed
254-
reverse(f"{APP_NAME}:render_panel")
255-
toolbar_urls_installed = True
256-
except NoReverseMatch:
252+
253+
if not hasattr(settings, "ROOT_URLCONF"):
254+
# reverse will raise AttributeError if ROOT_URLCONF is not defined
257255
toolbar_urls_installed = False
256+
else:
257+
try:
258+
# Check if the toolbar's urls are installed
259+
reverse(f"{APP_NAME}:render_panel")
260+
toolbar_urls_installed = True
261+
except NoReverseMatch:
262+
toolbar_urls_installed = False
258263

259264
# If the user is using the default SHOW_TOOLBAR_CALLBACK,
260265
# then the middleware will respect the change to settings.DEBUG.

docs/changes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Change log
33

44
Pending
55
-------
6+
* Prevent check from failing when ``ROOT_URLCONF`` is not defined.
67

78
6.3.0 (2026-04-01)
89
------------------

0 commit comments

Comments
 (0)