调试 django-channels

问题描述 投票:0回答:3

我正在尝试将 django-channels 合并到我的下一个项目中,但我在调试时遇到问题。我已经尝试过 pycharms 调试器和 pdb,但它没有达到断点。

django pycharm django-channels
3个回答
3
投票

查看 django 通道面板。它是 django 调试工具栏 的插件。您可以将 django-channels-panel 添加到此,以向您的项目添加通道调试功能。这确保您可以在应用程序处于开发模式时传递详细信息。

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

安装 [ Django 调试工具栏 ]

pip install django-debug-toolbar

在settings.py中

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

在 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)),
    ]

配置

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',
]

安装 [ Django 通道面板 ]

   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

1
投票

将 PYCHARM_DEBUG=True 添加到环境变量中为我解决了这个问题。

这增加了运行调试器时输出的大量额外日志记录,但即使从配置中删除 PYCHARM_DEBUG 值后,问题似乎仍然得到解决。


0
投票

这目前对我有用:

在Python调试设置中,确保Gevent兼容未勾选

我认为没有其他必要。更改此设置后,我的断点会被命中,而当勾选 Gevent 兼容时,它们不会被命中。

© www.soinside.com 2019 - 2024. All rights reserved.