Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sending activation emails-Django

I am creating an inactive user and want to send them email for activating there accounts like the one django-registration send when we create an account.

This is my views.py

user = User.objects.create_user(userName, userMail,userPass)
 user.is_active=False
 user.save()
like image 687
madeeha ameer Avatar asked Mar 22 '26 13:03

madeeha ameer


1 Answers

You should review the topical guide on sending emails. Basically, you'll just use the components from django.core.mail to send an activation email with all the necessary information after you've created the user instance.

It's important that that email contains further information on how the user is supposed to activate their account. The way django-registration does it is that it has a separate model associated with the User instance that specified a unique identifier which would be used in the activation view to identify which user account is supposed to be activated, i.e. creating a GET request to http://foo/accounts/activate/550e8400-e29b-41d4-a716-446655440000 would activate the user account with the associated UUID.

There are some other intricate details that make django-registration a thorough and well-polished solution, in spite of being a bit dated (i.e. no class-based views), so I second @NCao in suggesting that you take enough time to review the sources from the official repository and ripoff and duplicate all the necessary bits.

like image 126
Filip Dupanović Avatar answered Mar 24 '26 16:03

Filip Dupanović



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!