How to disable email activation in django-registration app?

前端 未结 5 620
忘了有多久
忘了有多久 2020-12-05 01:04

How to disable email activation in django-registration app?

5条回答
  •  无人及你
    2020-12-05 02:06

    Rather than modifying the registration app, why not just activate the user the same way django-registration does:

    user.is_active = True user.save() profile.activation_key = "ALREADY_ACTIVATED" profile.save()

    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)
    

提交回复
热议问题