Troubles with debug_toolbar

Dear All,

I have some troubles with ‘debug_toolbar’ and searching some help to debug the debug_toolbar or just investigate what I am doing wrong …

When I activate the debug_toolbar in my setting, it is not possible to launch my django project :
And I am block/freez in the performing system checks …

python3 manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

I give you here some part of my settings (if you need somme other info do note hesitates …)

DEBUG = True
ALLOWED_HOSTS =  ['localhost', '127.0.0.1','0.0.0.0']
INSTALLED_APPS = [
    'debug_toolbar',    
]
MIDDLEWARE = [
    'debug_toolbar.middleware.DebugToolbarMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
STATIC_URL = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "")

If I comment the ‘debug_toolbar’ in the INSTALLED_APPS, it is working fine
If I uncomment the ‘debug_toolbar’ in the INSTALLED_APPS, it is going wrong

Thanks for your help

If you hit Ctrl-C at the point that it freezes, do you get a stack trace? That would be useful to see what is freezing.

The toolbar performs some checks, so perhaps one of those is misbehaving: django-debug-toolbar/apps.py at main · jazzband/django-debug-toolbar · GitHub

Also please confirm your Python, Django, and django-debug-toolbar versions.

Hi,

Thanks for your help.

  1. Ctrl+C :
    No trace, just cut the process
>>> % python3 manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

^C%                                                                                                                                                                                                                                                                                        >>> % 
  1. Github
    I don’t understand what do you want me to do with this github ? what I have to verify ?

  2. Versions
    Python : 3.9.0
    Django : 3.1.7
    django-debug-toolbar : 3.2

Do you really only have one app in installed apps?
What about the rest of the DDT-related settings? The url changes for it?

Hi Ken,

I have several installed app …
Here the full part in settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django_extensions',  
    'dashboard.apps.DashboardConfig',
    'company.apps.CompanyConfig',
    'settings.apps.SettingsConfig',
    'mathfilters',
    'widget_tweaks',
    'django_filters',
    'import_export',
    'bootstrap_modal_forms',
    'crispy_forms',
    'taggit',
    'wkhtmltopdf',
    'django_elasticsearch_dsl',
    'debug_toolbar',    
]

And here is my urls.py

urlpatterns = [
    path('', views.home, name='home'),
    path('test', views.test, name='test'),
    path('__debug__/', include(debug_toolbar.urls)),

    path('dashboard/', include('dashboard.urls'), name='dashboard'),
    path('company/', include('company.urls'), name='company'),
    path('settings/', include('settings.urls'), name='settings'),
    # path('testos/', include('testos.urls'), name='testos'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

If it can help you … to help me :slight_smile:

Sorry, but I don’t have any concrete ideas - just some thoughts on gathering additional information to try to find a way to diagnose this.

What operating system are you using? Are you doing this in a virtual environment? (Always highly recommended)

I guess it’s possible that one of the other packages could be interfering with it.

Things you might try with absolutely no idea on their usefulness:

  • move debug_toolbar toward the top of the list of installed apps
  • remove other apps one at a time
  • running runserver different ways:
    • python3 manage.py runserver -v 3
    • python3 -u manage.py runserver -v 3
    • python3 -u -v manage.py runserver -v 3
      • Note: This is going to generate a lot of output that you’d probably want to capture to a file.
  • Try a different project with the simplest possible app to verify there’s nothing fundamentally wrong with the installation.
  • Try running it under the debugger to see if you can find where it’s getting hung up.

I know it’s tough when there’s no real information available.

I was pointing in the source to the system checks that DDT runs.


Also try:

PYTHONDEVMODE=1 manage.py runserver

then hit Ctrl-C.

Setting PYTHONDEVMODE activates Python’s development mode which includes faulthandler, which shows stack traces when you hit Ctrl-C whilst a C extension is running.

2 Likes