Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class RegistrationView(View):
- template_name = 'registration.html'
- def get(self, request):
- form = UserCreationForm(request.POST)
- return render(request, self.template_name, {'form': form})
- def post(self, request, *args, **kwargs):
- form = UserCreationForm(request.POST)
- if form.is_valid():
- form.save()
- username = form.cleaned_data.get('username')
- raw_password = form.cleaned_data.get('password1')
- user = authenticate(username=username, password=raw_password)
- login(request, user)
- return redirect('main_page')
- return render(request, self.template_name, {'form': form})
Add Comment
Please, Sign In to add comment