diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4c2d051f..12a61d9c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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: diff --git a/admin_panel/admin_panel/settings.py b/admin_panel/admin_panel/settings.py index 1bc0f428..8d11323c 100644 --- a/admin_panel/admin_panel/settings.py +++ b/admin_panel/admin_panel/settings.py @@ -1,3 +1,4 @@ +import importlib.util from pathlib import Path import dj_database_url @@ -16,6 +17,9 @@ DEBUG = True ALLOWED_HOSTS = [] +INTERNAL_IPS = [ + "127.0.0.1", +] # Application definition @@ -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 = [ diff --git a/admin_panel/admin_panel/urls.py b/admin_panel/admin_panel/urls.py index 0740a4f1..ae1b2d3d 100644 --- a/admin_panel/admin_panel/urls.py +++ b/admin_panel/admin_panel/urls.py @@ -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()) diff --git a/poetry.lock b/poetry.lock index 677d1e48..d810dd31 100644 --- a/poetry.lock +++ b/poetry.lock @@ -216,6 +216,20 @@ files = [ {file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"}, ] +[[package]] +name = "asgiref" +version = "3.8.1" +description = "ASGI specs, helper code, and adapters" +optional = false +python-versions = ">=3.8" +files = [ + {file = "asgiref-3.8.1-py3-none-any.whl", hash = "sha256:3e1e3ecc849832fe52ccf2cb6686b7a55f82bb1d6aee72a58826471390335e47"}, + {file = "asgiref-3.8.1.tar.gz", hash = "sha256:c343bd80a0bec947a9860adb4c432ffa7db769836c64238fc34bdc3fec84d590"}, +] + +[package.extras] +tests = ["mypy (>=0.800)", "pytest", "pytest-asyncio"] + [[package]] name = "asyncpg" version = "0.30.0" @@ -531,6 +545,41 @@ files = [ {file = "distlib-0.3.9.tar.gz", hash = "sha256:a60f20dea646b8a33f3e7772f74dc0b2d0772d2837ee1342a00645c81edf9403"}, ] +[[package]] +name = "django" +version = "5.1.4" +description = "A high-level Python web framework that encourages rapid development and clean, pragmatic design." +optional = false +python-versions = ">=3.10" +files = [ + {file = "Django-5.1.4-py3-none-any.whl", hash = "sha256:236e023f021f5ce7dee5779de7b286565fdea5f4ab86bae5338e3f7b69896cf0"}, + {file = "Django-5.1.4.tar.gz", hash = "sha256:de450c09e91879fa5a307f696e57c851955c910a438a35e6b4c895e86bedc82a"}, +] + +[package.dependencies] +asgiref = ">=3.8.1,<4" +sqlparse = ">=0.3.1" +tzdata = {version = "*", markers = "sys_platform == \"win32\""} + +[package.extras] +argon2 = ["argon2-cffi (>=19.1.0)"] +bcrypt = ["bcrypt"] + +[[package]] +name = "django-debug-toolbar" +version = "4.4.6" +description = "A configurable set of panels that display various debug information about the current request/response." +optional = false +python-versions = ">=3.8" +files = [ + {file = "django_debug_toolbar-4.4.6-py3-none-any.whl", hash = "sha256:3beb671c9ec44ffb817fad2780667f172bd1c067dbcabad6268ce39a81335f45"}, + {file = "django_debug_toolbar-4.4.6.tar.gz", hash = "sha256:36e421cb908c2f0675e07f9f41e3d1d8618dc386392ec82d23bcfcd5d29c7044"}, +] + +[package.dependencies] +django = ">=4.2.9" +sqlparse = ">=0.2" + [[package]] name = "fastapi" version = "0.115.6" @@ -1794,6 +1843,21 @@ files = [ {file = "sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"}, ] +[[package]] +name = "sqlparse" +version = "0.5.3" +description = "A non-validating SQL parser." +optional = false +python-versions = ">=3.8" +files = [ + {file = "sqlparse-0.5.3-py3-none-any.whl", hash = "sha256:cf2196ed3418f3ba5de6af7e82c694a9fbdbfecccdfc72e281548517081f16ca"}, + {file = "sqlparse-0.5.3.tar.gz", hash = "sha256:09f67787f56a0b16ecdbde1bfc7f5d9c3371ca683cfeaa8e6ff60b4807ec9272"}, +] + +[package.extras] +dev = ["build", "hatch"] +doc = ["sphinx"] + [[package]] name = "starlette" version = "0.41.3" @@ -1877,6 +1941,17 @@ files = [ {file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"}, ] +[[package]] +name = "tzdata" +version = "2024.2" +description = "Provider of IANA time zone data" +optional = false +python-versions = ">=2" +files = [ + {file = "tzdata-2024.2-py2.py3-none-any.whl", hash = "sha256:a48093786cdcde33cad18c2555e8532f34422074448fbc874186f0abd79565cd"}, + {file = "tzdata-2024.2.tar.gz", hash = "sha256:7d85cc416e9382e69095b7bdf4afd9e3880418a2413feec7069d533d6b4e31cc"}, +] + [[package]] name = "uvicorn" version = "0.32.1" @@ -2244,4 +2319,4 @@ propcache = ">=0.2.0" [metadata] lock-version = "2.0" python-versions = ">=3.12, <3.14" -content-hash = "1fee9fba0a9ca431059316aaf2f288fdaa8218ed370f5b076abb8d63b99abf2b" +content-hash = "d98eca1067acf4d235c5e3c92afe70e5571e816e7e2b440cdae87ca79119616d" diff --git a/pyproject.toml b/pyproject.toml index 8350abe0..426127a7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -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]