I'm rolling my own custom registration module in Django based on django.contrib.auth
. My registration module will have some extra functionality and help me reduce my dependency on other django modules that I'm currently using like django-registration and django-emailchange. I've run into a what-the-best-way-to-do-it problem here.
Note: All the user accounts are based on django.contrib.auth.models.User
model.
When the user clicks the "sign-up" link, the request gets passed to my view named register
. I have a custom form which has four fields — username, email, password1 and password2. The form is based on django.forms.Form
. The form provides basic validation e.g. passoword1 and password2 are the email; the email/username do not exist.
When the data gets POSTed back to my register view, I call the is_valid()
method of the form, after which, I create a new user by calling a Manager method called create_user()
in django.contrib.auth.models.UserManager
. I need to add more custom functionality at this point like sending activation emails, etc. As a best-practice method, where should this logic be? Should this be in a method of the User
Model? Should it be where it is currently - the Manager of the Model? Or should this be placed into a custom save()
method of my sign-up Form?
Thanks.