def signup(request):
if request.method == 'POST':
form = SignUpForm(request.POST)
if form.is_valid():
user = form.save()
user.refresh_from_db() # load the profile instance created by the signal
#user.profile.birth_date = form.cleaned_data.get('birth_date')
user.teacher.teacher_name = form.cleaned_data.get('teacher_name')
user.teacher.subjects = form.cleaned_data.get('subjects')
user.refresh_from_db()
user.save()
raw_password = form.cleaned_data.get('password1')
user = authenticate(username=user.username, password=raw_password)
login(request, user)
return redirect('home')
else:
form = SignUpForm()
return render(request, 'signup.html', {'form': form})
评论列表
文章目录