Add django-debug-toolbar
This commit is contained in:
parent
4e67e7299d
commit
d350b7bcd8
3 changed files with 20 additions and 6 deletions
|
|
@ -39,7 +39,7 @@ def env_int(key: str, default: int) -> int:
|
|||
|
||||
|
||||
DEBUG: bool = env_bool(key="DEBUG", default=True)
|
||||
RUNNING_TESTS: bool = "PYTEST_VERSION" in os.environ or any("pytest" in arg for arg in sys.argv)
|
||||
TESTING: bool = "test" in sys.argv or "PYTEST_VERSION" in os.environ
|
||||
|
||||
|
||||
def get_data_dir() -> Path:
|
||||
|
|
@ -142,12 +142,10 @@ INSTALLED_APPS: list[str] = [
|
|||
"django.contrib.contenttypes",
|
||||
"django.contrib.staticfiles",
|
||||
"twitch.apps.TwitchConfig",
|
||||
*(["silk"] if not RUNNING_TESTS else []),
|
||||
]
|
||||
|
||||
MIDDLEWARE: list[str] = [
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
*(["silk.middleware.SilkyMiddleware"] if not RUNNING_TESTS else []),
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
"django.middleware.common.CommonMiddleware",
|
||||
"django.middleware.csrf.CsrfViewMiddleware",
|
||||
|
|
@ -182,3 +180,15 @@ DATABASES: dict[str, dict[str, str | Path | dict[str, str]]] = {
|
|||
},
|
||||
},
|
||||
}
|
||||
|
||||
if not TESTING:
|
||||
INSTALLED_APPS = [
|
||||
*INSTALLED_APPS,
|
||||
"debug_toolbar",
|
||||
"silk",
|
||||
]
|
||||
MIDDLEWARE = [
|
||||
"debug_toolbar.middleware.DebugToolbarMiddleware",
|
||||
"silk.middleware.SilkyMiddleware",
|
||||
*MIDDLEWARE,
|
||||
]
|
||||
|
|
|
|||
|
|
@ -15,12 +15,15 @@ urlpatterns: [URLPattern | URLResolver] = [ # type: ignore[assignment]
|
|||
path(route="", view=include("twitch.urls", namespace="twitch")),
|
||||
]
|
||||
|
||||
if getattr(settings, "ENABLE_SILK", False):
|
||||
urlpatterns += [path("silk/", include("silk.urls", namespace="silk"))]
|
||||
|
||||
# Serve media in development
|
||||
if settings.DEBUG:
|
||||
urlpatterns += static(
|
||||
settings.MEDIA_URL,
|
||||
document_root=settings.MEDIA_ROOT,
|
||||
)
|
||||
|
||||
if not settings.TESTING:
|
||||
from debug_toolbar.toolbar import debug_toolbar_urls
|
||||
|
||||
urlpatterns += [path("silk/", include("silk.urls", namespace="silk"))]
|
||||
urlpatterns = [*urlpatterns, *debug_toolbar_urls()]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue