python - how to send email confirmation mail, after post_save signal with djanago-allauth -


i using django-allauth in webapp account management.

i have user model , userprofile model.

when user gets signs creates user(an instance in user model).

userprofile assosiated model user.

allauth default sends email when user signs up,a confirmation email sent user when signs up.

now want send email when fills userprofile.

i thiking use signals here. when user fill userprofile, call post_save signal , calls function user_signed_up_ facing problem in passing request , user args function.

here models.py

from django.db import models django.contrib.auth.models import user allauth.account.signals import user_signed_up allauth.account.utils import send_email_confirmation django.dispatch import receiver import datetime  class userprofile(models.model):     user = models.foreignkey(user, unique=true)      are_u_intrested = models.booleanfield(default=false)   #this signal called when user signs up.allauth send signal.  @receiver(user_signed_up, dispatch_uid="some.unique.string.id.for.allauth.user_signed_up") def user_signed_up_(request, user, **kwargs):      send_email_confirmation(request, user, signup=true)     #this allauth util method, sends confirmation email user.      models.signals.post_save.connect(user_signed_up_, sender=userprofile, dispatch_uid="update_stock_count")  #if user fills userprofile , send confirmation mail. #if userprofile model instace saved , send post_save signal. 

you don't need using allauth's signals here, need using django's model signals. like:

from django.db.models.signals import post_save django.dispatch import receiver  @receiver(post_save, sender=userprofile) def userprofile_filled_out(sender, instance, created, raw, **kwargs):     # don't want send on creation or raw      if created or raw:         return      # test existence of fields want populated before     # sending email     if instance.field_we_want_populated:        send_mail(...) 

hope helps!


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -