are there learning activities for django-debug-toolbar
- Install django-debug-toolbar:
pip install django-debug-toolbar
- Add
'debug_toolbar'
to yourINSTALLED_APPS
insettings.py
:
INSTALLED_APPS = [
# ...
'debug_toolbar',
# ...
]
- Add
'debug_toolbar.middleware.DebugToolbarMiddleware'
to yourMIDDLEWARE
insettings.py
:
MIDDLEWARE = [
# ...
'debug_toolbar.middleware.DebugToolbarMiddleware',
# ...
]
- Configure the
INTERNAL_IPS
setting insettings.py
:
INTERNAL_IPS = [
# ...
'127.0.0.1',
# ...
]
- Configure the
DEBUG_TOOLBAR_PANELS
setting insettings.py
to include desired panels:
DEBUG_TOOLBAR_PANELS = [
# ...
'debug_toolbar.panels.timer.TimerPanel',
'debug_toolbar.panels.headers.HeadersPanel',
# Add more panels as needed
# ...
]
- (Optional) Configure other settings as needed, such as
DEBUG_TOOLBAR_CONFIG
:
DEBUG_TOOLBAR_CONFIG = {
# ...
'SHOW_TOOLBAR_CALLBACK': lambda request: True,
# ...
}
- Include the toolbar URLs in your project's
urls.py
for the development environment:
if settings.DEBUG:
import debug_toolbar
urlpatterns = [
# ...
path('__debug__/', include(debug_toolbar.urls)),
# ...
] + urlpatterns
- Run your Django development server:
python manage.py runserver
Access your application in a web browser, and you should see the debug toolbar.
Explore the debug toolbar panels to analyze various aspects of your Django application's performance and behavior.