Skip to content

Commit 7c656ba

Browse files
Merge pull request #64 from SADiLaR/feature/debug-tool
added debug tool
2 parents 6248706 + 589ca50 commit 7c656ba

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

app/app/settings.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@
4848
"general",
4949
"simple_history",
5050
]
51+
52+
# Add django-extensions to the installed apps if DEBUG is True
5153
if DEBUG:
5254
INSTALLED_APPS += [
5355
"django_extensions",
56+
"debug_toolbar",
5457
]
5558

5659
AUTH_USER_MODEL = "users.CustomUser"
@@ -68,6 +71,10 @@
6871
"django.middleware.locale.LocaleMiddleware",
6972
]
7073

74+
# Add debug toolbar middleware
75+
if DEBUG:
76+
MIDDLEWARE.insert(0, "debug_toolbar.middleware.DebugToolbarMiddleware")
77+
7178
ROOT_URLCONF = "app.urls"
7279

7380
TEMPLATES = [
@@ -104,6 +111,18 @@
104111
}
105112
}
106113

114+
# toolbar settings
115+
if DEBUG:
116+
DEBUG_TOOLBAR_CONFIG = {
117+
"IS_RUNNING_TESTS": False,
118+
"SHOW_TOOLBAR_CALLBACK": lambda request: DEBUG,
119+
}
120+
121+
INTERNAL_IPS = [
122+
"host.docker.internal",
123+
]
124+
125+
# Check if the application is under testing
107126
if "test" in sys.argv or "test_coverage" in sys.argv: # Covers regular testing and django-coverage
108127
DATABASES["default"]["ENGINE"] = "django.db.backends.sqlite3"
109128

@@ -144,13 +163,12 @@
144163
# Static files (CSS, JavaScript, Images)
145164
# https://docs.djangoproject.com/en/5.0/howto/static-files/
146165

147-
166+
# Static files (CSS, JavaScript, Images)
148167
if DEBUG:
149168
_STATICFILES_BACKEND = "django.contrib.staticfiles.storage.StaticFilesStorage"
150169
else:
151170
_STATICFILES_BACKEND = "whitenoise.storage.CompressedManifestStaticFilesStorage"
152171

153-
154172
STATIC_URL = "/static/"
155173
STATICFILES_DIRS = [
156174
BASE_DIR / "static",
@@ -192,6 +210,7 @@
192210
if "test" in sys.argv:
193211
DEBUG = False
194212

213+
# Logging configuration
195214
if DEBUG:
196215
LOGGING = {
197216
"version": 1,

app/app/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@
3737

3838
if settings.DEBUG:
3939
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
40+
urlpatterns.append(path("__debug__/", include("debug_toolbar.urls")))

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ services:
2929
- "8000:8000"
3030
depends_on:
3131
- db
32+
extra_hosts:
33+
- "host.docker.internal:host-gateway"
3234
environment:
3335
# TODO: dollar signs in the KEY are interpolated, therefore escaped here
3436
# with double "$$". Maybe move to .env file to simplify?

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
-r requirements.txt
2+
django-debug-toolbar
23
django-extensions
34
pygraphviz
45
ruff

requirements-test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
-r requirements.txt
2+
django-debug-toolbar
23
django-extensions
34
ruff
45
faker

0 commit comments

Comments
 (0)