[英]Django LogoutView does not emit user_logged_out signal
I have an app that does not receive the user_logged_out
signal that, in theory, should have been sent by LogoutView
. 我有一个应用程序没有收到
user_logged_out
信号,该信号理论上应该由LogoutView
发送。
urls.py: urls.py:
...
path('accounts/logout/',
auth_views.LogoutView.as_view(template_name='registration/logout.html'),
name='logout'),
...
myapp/signals.py MYAPP / signals.py
from django.contrib.auth import user_logged_out
from django.dispatch import receiver
@receiver(user_logged_out)
def extra_logout(sender, request, user, **kwargs):
# does some stuff
myapp/apps.py MYAPP / apps.py
from django.apps import AppConfig
class MyappConfig(AppConfig):
name = 'myapp'
def ready(self):
import myapp.signals
return super().ready()
Note that myapp
is loaded, everything else works. 请注意,
myapp
已加载,其他一切正常。 The django session is destroyed when calling accounts/logout/
, but my receiver never gets the signal. 调用
accounts/logout/
,django会话被破坏了,但是我的接收器从未收到信号。
What am I doing wrong? 我究竟做错了什么?
Django 2.2.3, Python 3.7.3 on mac. Mac上的Django 2.2.3,Python 3.7.3
Just tried with your code and the missing part could be the default_app_config = 'myapp.apps.MyappConfig'
line in the __init__.py file in myapp folder. 只需尝试使用您的代码,缺少的部分可能是myapp文件夹中__init__.py文件中的
default_app_config = 'myapp.apps.MyappConfig'
行。 Please check with that and see if it works. 请检查一下是否可行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.