Skip to content

Commit

Permalink
add django-debug-toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
ot-nemoto committed Jun 24, 2024
1 parent dab2101 commit 12ebf99
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,36 @@ coverage report
coverage html
# Wrote HTML report to htmlcov/index.html
```

### Writing your first Django app, part 8

**django-debug-toolbar**

_settings.py_

```python
INSTALLED_APPS = [
...
'debug_toolbar',
]

MIDDLEWARE = [
...
'debug_toolbar.middleware.DebugToolbarMiddleware',
]

INTERNAL_IPS = [
'127.0.0.1',
]
```

_urls.py_

```python
from django.urls import path, include

urlpatterns = [
...
path('__debug__/', include('debug_toolbar.urls')),
]
```
6 changes: 6 additions & 0 deletions mysite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"django.contrib.messages", # A messaging framework.
"django.contrib.staticfiles", # A framework for managing static files.
"polls.apps.PollsConfig",
"debug_toolbar",
]

MIDDLEWARE = [
Expand All @@ -48,6 +49,7 @@
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"debug_toolbar.middleware.DebugToolbarMiddleware",
]

ROOT_URLCONF = "mysite.urls"
Expand Down Expand Up @@ -126,3 +128,7 @@
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

INTERNAL_IPS = [
"127.0.0.1",
]
3 changes: 2 additions & 1 deletion mysite/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
urlpatterns = [
path("polls/", include("polls.urls")),
path("admin/", admin.site.urls),
]
path("__debug__/", include("debug_toolbar.urls")),
]
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
django
mysqlclient
coverage
django-debug-toolbar

0 comments on commit 12ebf99

Please sign in to comment.