All the example can not figure out how to log the user? it turns out that adding another method to the view or changing the method does not work, that is, it turns out but when authenticating, the method gives the value NONE. how to do it?
lass 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) with authorization added
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 it turns out that the username and password I get and pass them to the method, but the answer is from the None method, you might think that he simply does not find such a user because he has not yet been saved in the database. but the form_valid (form) method just takes a redirect to the specified URL. If the presentation is written with non-CBV logic, then the authorization works in it normally.