Skip to content

Commit 8f9bf98

Browse files
authored
Merge pull request #32 from yld-weng/test/ylw
build: add django-debug-toolbar
2 parents e7504f5 + 8787c3e commit 8f9bf98

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,15 @@ python manage.py createsuperuser
5959

6060
---
6161

62-
6. Finally, run start the development server
62+
6. Create a `.env` file in the project root directory and add the following environment variables:
63+
64+
```
65+
DJANGO_SECRET_KEY=your_secret_key
66+
```
67+
68+
---
69+
70+
7. Finally, run start the development server
6371
```bash
6472
python manage.py runserver
6573
```

SORT/settings.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"django.contrib.staticfiles",
4444
"django_bootstrap5",
4545
"django_extensions",
46+
'debug_toolbar',
4647

4748
# apps created by FA:
4849

@@ -59,6 +60,7 @@
5960
"django.contrib.auth.middleware.AuthenticationMiddleware",
6061
"django.contrib.messages.middleware.MessageMiddleware",
6162
"django.middleware.clickjacking.XFrameOptionsMiddleware",
63+
'debug_toolbar.middleware.DebugToolbarMiddleware'
6264
]
6365

6466
ROOT_URLCONF = "SORT.urls"
@@ -163,7 +165,14 @@
163165
'django.contrib.auth.backends.ModelBackend',
164166
)
165167

168+
# For django-debug-toolbar
169+
INTERNAL_IPS = [
170+
# ...
171+
"127.0.0.1",
172+
# ...
173+
]
166174

167175
# FA: for production:
168176

169177
#EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
178+

SORT/urls.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,17 @@
1414
1. Import the include() function: from django.urls import include, path
1515
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
1616
"""
17+
from django.conf import settings
1718
from django.contrib import admin
1819
from django.urls import path, include
1920

2021
urlpatterns = [
2122
path("admin/", admin.site.urls),
2223
path("", include("home.urls")),
2324
]
25+
26+
if settings.DEBUG:
27+
import debug_toolbar
28+
urlpatterns += [
29+
path('__debug__/', include(debug_toolbar.urls)),
30+
]

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ traitlets==5.14.3
2424
typing_extensions==4.12.2
2525
tzdata==2024.1
2626
wcwidth==0.2.13
27+
django_debug_toolbar==4.4.6

0 commit comments

Comments
 (0)