首页 > 解决方案 > 信号似乎没有连接

问题描述

我正在使用 Django 3.0.8。

设置.py

INSTALLED_APPS = [
    'admin_aux.apps.AdminAuxConfig', # PROJECT_APPS

应用程序.py

from django.apps import AppConfig


class AdminAuxConfig(AppConfig):
    name = 'admin_aux'

    def ready(self):
        import admin_aux.allauth_avatar # Breakpoint. Stopps here when the server is run.

admin_aux/allauth_avatar.py

@receiver(user_signed_up) # Breakpoint. Doesn't stop here when the server is run.
def on_user_signed_up(sender, request, *args, **kwargs):
    sociallogin = kwargs.get('sociallogin')
    if sociallogin:
        copy_avatar(request,
                    sociallogin.account.user,
                    sociallogin.account)

问题:接收器没有接收到信号。

我在代码中标记了断点。

当我在 PyCharm 中运行调试时,我希望解释器会在 allauth_avatar.py 中的断点处停止。但事实并非如此。所以,信号似乎没有连接。我该如何解决这个问题?

标签: djangodjango-signals

解决方案


推荐阅读