Skip to content

Single source 'djdt' app name #1588

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions debug_toolbar/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
__all__ = ["VERSION"]
__all__ = ["APP_NAME", "VERSION"]

APP_NAME = "djdt"

# Do not use pkg_resources to find the version but set it here directly!
# see issue #1446
VERSION = "3.2.4"

# Code that discovers files or modules in INSTALLED_APPS imports this module.
urls = "debug_toolbar.urls", "djdt" # See debug_toolbar/urls.py
urls = "debug_toolbar.urls", APP_NAME
6 changes: 2 additions & 4 deletions debug_toolbar/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from django.urls.exceptions import Resolver404
from django.utils.module_loading import import_string

from debug_toolbar import settings as dt_settings
from debug_toolbar import APP_NAME, settings as dt_settings


class DebugToolbar:
Expand Down Expand Up @@ -144,8 +144,6 @@ def is_toolbar_request(cls, request):
"""
Determine if the request is for a DebugToolbar view.
"""
from debug_toolbar.urls import app_name

# The primary caller of this function is in the middleware which may
# not have resolver_match set.
try:
Expand All @@ -154,7 +152,7 @@ def is_toolbar_request(cls, request):
)
except Resolver404:
return False
return resolver_match.namespaces and resolver_match.namespaces[-1] == app_name
return resolver_match.namespaces and resolver_match.namespaces[-1] == APP_NAME

@staticmethod
@lru_cache(maxsize=128)
Expand Down
3 changes: 2 additions & 1 deletion debug_toolbar/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from debug_toolbar import APP_NAME
from debug_toolbar.toolbar import DebugToolbar

app_name = "djdt" # See debug_toolbar/__init__.py
app_name = APP_NAME
urlpatterns = DebugToolbar.get_urls()