Answer the question
In order to leave comments, you need to log in
How to make field user.is_active = True by default(django-registration-redux)?
Continuing my topic about registering for Django.
I redefined my form and now it looks like this
class RegistrationForm(RegistrationFormUniqueEmail):
first_name = forms.CharField(label=u"First Name", required=True)
last_name = forms.CharField(label=u"Last Name", required=True)
username = forms.CharField(label=None)
email = forms.CharField(label=None)
password1 = forms.CharField(label="Password", widget=forms.PasswordInput)
password2 = forms.CharField(label="Password confirmation", widget=forms.PasswordInput)
def save(self, profile_callback=None):
new_user = User.objects.create_user(username=self.cleaned_data['username'],
password=self.cleaned_data['password1'],
email=self.cleaned_data['email'],
first_name=self.cleaned_data['first_name'],
last_name=self.cleaned_data['last_name'],
)
new_user.is_active = True
new_user.save()
g = Group.objects.get(name='users')
g.user_set.add(new_user)
return new_user
Answer the question
In order to leave comments, you need to log in
new_user = User.objects.create_user(username=self.cleaned_data['username'],
password=self.cleaned_data['password1'],
email=self.cleaned_data['email'],
first_name=self.cleaned_data['first_name'],
last_name=self.cleaned_data['last_name'],
)
new_user.is_active = True
new_user.save()
new_user = User.objects.create_user(username=self.cleaned_data['username'],
password=self.cleaned_data['password1'],
email=self.cleaned_data['email'],
first_name=self.cleaned_data['first_name'],
last_name=self.cleaned_data['last_name'],
is_active=True,
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question