Guest User

Untitled

a guest
Jun 27th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. from django.shortcuts import render, redirect
  2. from django.contrib.auth import authenticate, login
  3. from account.forms import RegistrationForm
  4. from django.contrib.auth.forms import UserChangeForm
  5.  
  6. def sign_up(request):
  7. if request.method == 'POST':
  8. form = RegistrationForm(request.POST)
  9. if form.is_valid():
  10. form.save()
  11. username = form.cleaned_data['username']
  12. password = form.cleaned_data['password1']
  13. user = authenticate(username=username, password=password)
  14. login(request, user)
  15. return redirect('/account/profile')
  16. else:
  17. form = RegistrationForm()
  18. context = {'form': form}
  19. return render(request, 'sign_up.html', context)
Add Comment
Please, Sign In to add comment