Reputation: 1833
I have an app that does not receive the user_logged_out
signal that, in theory, should have been sent by LogoutView
.
urls.py:
...
path('accounts/logout/',
auth_views.LogoutView.as_view(template_name='registration/logout.html'),
name='logout'),
...
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
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. The django session is destroyed when calling accounts/logout/
, but my receiver never gets the signal.
What am I doing wrong?
Django 2.2.3, Python 3.7.3 on mac.
Upvotes: 0
Views: 376
Reputation: 3588
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. Please check with that and see if it works.
Upvotes: 1