Django - authentication, registration with email confirmation

Viewed 17956

I'm looking at the API for authentication

https://docs.djangoproject.com/en/1.3/topics/auth/

I can't seem to find information on simple user registration form that would send confirmation email as it is the usual way on web sites.

I guess I could do this:

1) Display a form 2) User enters info and submits 3) Save user as inactive, with a confirmation code 4) Send a link with confirmation code 5) User clicks a confirmation link and becomes active

It doesn't seem that difficult but I have a feeling this might be done already, and also there are quite a few edge cases that would need to be considered.

3 Answers

You can do this:

  • Define a function to activate the user (i. e. def activate(request))
    • Configure in the url.py the route to that function (i.e /activate/)
  • Create a form to register user
  • Create the post function to create the user
    • When you create the user set field 'is_active' to 0.
    • In the same function send the email with a link inside, this link must have the target as the configured route
Related