Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from socialapp.forms import SignUpForm
- from django.shortcuts import render
- def signup(request):
- if request.user.is_authenticated:
- return redirect('/')
- if request.method == 'POST':
- form = SignUpForm(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('/')
- else:
- form = SignUpForm()
- return render(request, 'registration/signup.html', {'form': form})
Add Comment
Please, Sign In to add comment