Skip to content

Commit

Permalink
add django-debug-toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
laggron42 committed Jan 10, 2025
1 parent 9dcc49e commit 07e53f6
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 1 deletion.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ repos:
- django
- dj_database_url
- django-stubs
- django-debug-toolbar
- repo: https://github.com/csachs/pyproject-flake8
rev: v7.0.0
hooks:
Expand Down
8 changes: 8 additions & 0 deletions admin_panel/admin_panel/settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import importlib.util
from pathlib import Path

import dj_database_url
Expand All @@ -16,6 +17,9 @@
DEBUG = True

ALLOWED_HOSTS = []
INTERNAL_IPS = [
"127.0.0.1",
]


# Application definition
Expand All @@ -41,6 +45,10 @@
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]

if DEBUG and importlib.util.find_spec("debug_toolbar") is not None:
INSTALLED_APPS.append("debug_toolbar")
MIDDLEWARE.append("debug_toolbar.middleware.DebugToolbarMiddleware")

ROOT_URLCONF = "admin_panel.urls"

TEMPLATES = [
Expand Down
8 changes: 8 additions & 0 deletions admin_panel/admin_panel/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@
+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
)

if settings.DEBUG:
try:
from debug_toolbar.toolbar import debug_toolbar_urls
except ImportError:
pass
else:
urlpatterns.extend(debug_toolbar_urls())
77 changes: 76 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ uvicorn = "^0.32.0"
tortoise-orm = {extras = ["asyncpg"], version = "^0.22.2"}
tortoise-cli = "^0.1.2"

# django admin panel
django = "^5.1.4"

# misc
rich = "^13.8.0"
python-dateutil = "^2.9.0"
Expand All @@ -38,6 +41,7 @@ black = {version = "^24.8.0", allow-prereleases = true}
flake8-pyproject = "^1.2.3"
pyright = "^1.1.335"
isort = "^5.13.2"
django-debug-toolbar = "^4.4.6"


[tool.poetry.group.metrics.dependencies]
Expand Down

0 comments on commit 07e53f6

Please sign in to comment.