How to disable email activation in django-registration app?
5 Answers
In the current tip versions of django-registration there is a simple backend with no email and you can write your own backend to specify the workflow you want. See here https://bitbucket.org/ubernostrum/django-registration/src/fad7080fe769/docs/backend-api.rst for documentation.
To use the simple one without email, just change your urls.py to point to this backend, eg.
(r'^accounts/', include('registration.backends.simple.urls')),

- 8,434
- 8
- 57
- 76
Why not use this method and just use the simple backend that comes with django-registration instead of the default backend?
The new work flow would be... 1. A user signs up by filling out a registration form. 2. The user’s account is created and is active immediately, with no intermediate confirmation or activation step. 3. The new user is logged in immediately.
so on your main urls.py you would change:
url(r'^accounts/', include('registration.backends.default.urls')),
to
url(r'^accounts/', include('registration.backends.simple.urls')),

- 5,524
- 5
- 37
- 43
Better to fix the problem at the root than bandage it by calling commands to automatically activate the user.
Add this method to registration models.py:
def create_active_user(self, username, email, password,
site):
"""
Create a new, active ``User``, generate a
``RegistrationProfile`` and email its activation key to the
``User``, returning the new ``User``.
"""
new_user = User.objects.create_user(username, email, password)
new_user.is_active = True
new_user.save()
registration_profile = self.create_profile(new_user)
return new_user
create_active_user = transaction.commit_on_success(create_active_user)
Then, edit registration/backend/defaults/init.py and find the register() method.
Change the following to call your new method:
#new_user = RegistrationProfile.objects.create_inactive_user(username, email,
#password, site)
new_user = RegistrationProfile.objects.create_active_user(username, email,
password, site)

- 3,188
- 5
- 27
- 40
-
i followed your procedure but when i enter the user it is not coming as activated. – XMen Jan 21 '12 at 11:19
You could always modify this line to:
new_user = RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'],
password=self.cleaned_data['password1'],
email=self.cleaned_data['email'],
profile_callback=profile_callback,
send_email = False)
Or you could change this line to:
def create_inactive_user(self, username, password, email,
send_email=False, profile_callback=None):

- 97,747
- 36
- 197
- 212
-
2You need to call activate_user though (or else the user's account will be unusable) – Jiaaro Dec 03 '09 at 17:04
-
1In new version of django-register, file forms.py doesn't like this so far. Check this link: http://bitbucket.org/ubernostrum/django-registration/src/tip/registration/forms.py – anhtran Dec 04 '09 at 05:08
-
this is really simple to do without modifying the code. oh snap. i didn't realize how old this answer was... – teewuane Feb 08 '13 at 18:24
-
The whole answer is deprecated it seems, including all the links and the logic being in a different place. – erikbstack Sep 09 '16 at 14:31
Rather than modifying the registration app, why not just activate the user the same way django-registration does:
After looking at it even more... I think what you want is to use both solutions. Probably add the above code, just after the change suggested by Dominic (though I would suggest using signals, or subclassing the form if possible)
OK final Answer:
new_user = RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'],
password=self.cleaned_data['password1'],
email=self.cleaned_data['email'],
profile_callback=profile_callback,
send_email = False)
RegistrationProfile.objects.activate_user(new_user.activation_key)

- 74,485
- 42
- 169
- 190
-
Did I get it wrong? I've not tried my code out, just took a look at the code in django-registration. – Dominic Rodger Dec 03 '09 at 16:47
-
No I actually just edited my answer because I think both of our solutions are necessary :) – Jiaaro Dec 03 '09 at 16:49
-
where does this go? do you know of a way to do this without modifying the django-registration code? I'm thinking like a signal to when the user is created.. – teewuane Feb 08 '13 at 18:03