7

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.

Mantis
  • 1,357
  • 3
  • 27
  • 49
  • There is a package for debugging Django channels added into Channels community project. Please check it out... http://channels.readthedocs.io/en/latest/community.html – Raja Simon Sep 13 '16 at 06:33

3 Answers3

3

Take a look into django channels panel. It is a plugin to django debug toolbar. 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
ahumblenerd
  • 205
  • 3
  • 12
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/14023575) – Matt Cremeens Oct 18 '16 at 20:50
  • 1
    @MattCremeens I have now added a more detailed answer with sufficient code examples on top of the installation links – ahumblenerd Oct 20 '16 at 15:03
1

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.

Tonis F. Piip
  • 776
  • 2
  • 6
  • 16
0

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.

Tim Richardson
  • 6,608
  • 6
  • 44
  • 71