Answer the question
In order to leave comments, you need to log in
Authorization after user registration, how?
Hello, I have a question, I have a form and a view based on cbv
class UserFormView(CreateView):
form_class= MyUserCreationForm
template_name='registration/reg.html'
def form_valid(self, form):
form.instance.user = self.request.user
return super(UserFormView, self).form_valid(form)
class UserFormView(CreateView):
form_class= MyUserCreationForm
template_name='registration/reg.html'
def form_valid(self, form):
form.instance.user = self.request.user
username = self.request.POST['username']
password = self.request.POST['password2']
print(username)
print(password)
userauth = authenticate(self.request,username=username,password=password)
print(userauth)
if userauth is not None:
if userauth.is_active:
login(self.request, userauth)
return super(UserFormView, self).form_valid(form)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question