You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wrote something a while back you can take bits and pieces from this
@receiver(post_save, sender=Student)defsend_cofirm_email(sender , instance , created , **kwargs):
ifcreated:
sent=signup(instance)
ifnotsent:
raiseException('Email Verification Not Sent')
defsignup(student):
mail_subject='Activate your blog account.'message=render_to_string('users/account_activate_email.html', {
'user': student.user,
'domain': 'localhost:8000',
'uid': urlsafe_base64_encode(force_bytes(student.pk)),
'token': student.token,
})
to_email=student.user.emailemail=EmailMessage(
mail_subject, message, to=[to_email]
)
email.send()
returnTrue
defactivate_account(request, uidb64, token):
try:
uid=force_text(urlsafe_base64_decode(uidb64))
student=Student.objects.get(pk=uid)
except(TypeError, ValueError, OverflowError, Student.DoesNotExist):
student=Noneprint(token)
ifstudentisnotNoneandstr(token) ==str(student.token):
student.user.is_active=Truestudent.user.save()
returnHttpResponse('Thank you for your email confirmation. Now you can login your account.')
else:
raiseException('Activation link is invalid!')
No description provided.
The text was updated successfully, but these errors were encountered: