Mantis
Mantis

Reputation: 1387

Debugging django-channels

I'm trying to incorporate django-channels into my next project but I am having issues debugging. I have tried pycharms debugger and also pdb but it does not hit the breakpoints.

Upvotes: 7

Views: 3089

Answers (3)

ahumblenerd
ahumblenerd

Reputation: 225

Take a look into django channels panel. It is a plugin to django debug toolbar, though it does not support channels 2.0 and the project was archived on Sep 28, 2020.

You can add django-channels-panel to this to add channel debug functionality to your project. This ensures that you can channel details when your app is in development mode.

https://github.com/Krukov/django-channels-panel

Installation [ Django debug toolbar ]

pip install django-debug-toolbar

In settings.py

INSTALLED_APPS = [
    # ...
    'django.contrib.staticfiles',
    # ...
    'debug_toolbar',
]
MIDDLEWARE = [
    # ...
    'debug_toolbar.middleware.DebugToolbarMiddleware',
    # ...
]

In urls.py

from django.conf import settings
from django.conf.urls import include, url

if settings.DEBUG:
    import debug_toolbar
    urlpatterns += [
        url(r'^__debug__/', include(debug_toolbar.urls)),
    ]

Configuration

DEBUG_TOOLBAR_PANELS = [
    'debug_toolbar.panels.versions.VersionsPanel',
    'debug_toolbar.panels.timer.TimerPanel',
    'debug_toolbar.panels.settings.SettingsPanel',
    'debug_toolbar.panels.headers.HeadersPanel',
    'debug_toolbar.panels.request.RequestPanel',
    'debug_toolbar.panels.sql.SQLPanel',
    'debug_toolbar.panels.staticfiles.StaticFilesPanel',
    'debug_toolbar.panels.templates.TemplatesPanel',
    'debug_toolbar.panels.cache.CachePanel',
    'debug_toolbar.panels.signals.SignalsPanel',
    'debug_toolbar.panels.logging.LoggingPanel',
    'debug_toolbar.panels.redirects.RedirectsPanel',
]

Installation [ Django channels panel ]

   pip install django-channels-panel

   add 'channels_panel' to your INSTALLED_APPS in settings.py

   add 'channels_panel.panel.ChannelsDebugPanel' to your DEBUG_TOOLBAR_PANELS

Upvotes: 4

Tim Richardson
Tim Richardson

Reputation: 7231

This is what works for me currently:

In the Python debugging settings, make sure Gevent-compatible is unticked

I don't think anything else is necessary. My breakpoints are hit after this setting is changed, and they are not hit when Gevent-compatible is ticked.

Upvotes: 0

Tonis F. Piip
Tonis F. Piip

Reputation: 806

Adding PYCHARM_DEBUG=True to the environment variables solved this for me.

This adds a lot of extra logging to be outputted when running the debugger, but it seems that the problem remains fixed even after removing the PYCHARM_DEBUG value from the config.

Upvotes: 1

Related Questions