Guest User

Untitled

a guest
Jul 4th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. from socialapp.forms import SignUpForm
  2. from django.shortcuts import render
  3.  
  4. def signup(request):
  5. if request.user.is_authenticated:
  6. return redirect('/')
  7. if request.method == 'POST':
  8. form = SignUpForm(request.POST)
  9. if form.is_valid():
  10. form.save()
  11. username = form.cleaned_data.get('username')
  12. raw_password = form.cleaned_data.get('password1')
  13. user = authenticate(username=username, password=raw_password)
  14. login(request, user)
  15. return redirect('/')
  16. else:
  17. form = SignUpForm()
  18. return render(request, 'registration/signup.html', {'form': form})
Add Comment
Please, Sign In to add comment