Advertisement
Darkolius

Untitled

Mar 27th, 2021
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. from django.shortcuts import render
  2. from django.contrib.auth.models import User
  3. from .forms import SignUpForm
  4.  
  5.  
  6. def index(request):
  7.     return render(request, 'school/index.html')
  8.  
  9.  
  10. def sign_up(request):
  11.     context ={}
  12.     form = SignUpForm(request.POST or None)
  13.     if request.method == "POST":
  14.         if form.is_valid():
  15.             user = form.save()
  16.             user.refresh_from_db()
  17.             user.profile.first_name = form.cleaned_data.get('first_name')
  18.             user.profile.last_name = form.cleaned_data.get('last_name')
  19.             user.save()
  20.             return render(request, 'school/dashboard.html')
  21.     context['form'] = form
  22.     return render(request, 'registration/sign_up.html', context)
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement