问题
Signals page for django-allauth: https://django-allauth.readthedocs.io/en/latest/signals.html
I am trying to hook the email_verified signal:
allauth.account.signals.email_confirmed(request, email_address)
And am getting nothing whenever a user confirms their email. Here is my code:
from allauth.account.signals import email_confirmed
from channels import Group
def send_to_user_socket(sender, **kwargs):
Group('%s.get-started' % (kwargs['request'].user.username)).send({'text': json.dumps({'message': 'Email confirmed'})})
email_confirmed.connect(send_to_user_socket)
What am I doing wrong? Thanks in advance.
Edit: here is my apps.py code:
from django.apps import AppConfig
class EngineConfig(AppConfig):
name = 'engine'
def ready(self):
import engine.signals
回答1:
I had a similar issue, but it was resolved by doing the following
In your init.py file within the particular app, add
default_app_config = "{enter_you_app_name}.apps.{Appname}Config"
eg
default_app_config = "authentication.apps.AuthenticationConfig"
also import
from django.dispatch import receiver
@reciever(enter_the_correct_details)
def send_to_user_socket(sender, **kwargs):
Group('%s.get-started' % (kwargs['request'].user.username)).send({'text': json.dumps({'message': 'Email confirmed'})})
email_confirmed.connect(send_to_user_socket)
来源:https://stackoverflow.com/questions/51509224/how-do-i-hook-a-django-allauth-signal