Answers for "django signup form"

0

signup view

from django.contrib.auth import authenticate

class SignUpView(CreateView):
    form_class 		= UserRegistrationForm
    success_url 	= reverse_lazy('home')
    template_name	= 'registration/signup.html'
    
    def form_valid(self, form):
        view        = super(SignUpView, self).form_valid(form)
        username    = form.cleaned_data.get('username')
        password    = form.cleaned_data.get('password1')
        user        = authenticate(username=username, password=password)       
        login(self.request, user)
        return view
Posted by: Guest on September-16-2020

Python Answers by Framework

Browse Popular Code Answers by Language