def register(request):
if request.method == 'POST':
user_form = UserRegistrationForm(request.POST)
if user_form.is_valid():
new_user = user_form.save()
new_user.first_name = user_form.cleaned_data['first_name']
new_user.last_name = user_form.cleaned_data['last_name']
new_user.set_password(user_form.cleaned_data['password'])
new_user.save()
return render(request, 'main.html', {'new_user': new_user})
else:
messages.error(request, 'Такой пользователь существует')
else:
user_form = UserRegistrationForm()
return render(request, 'account/register.html', {'user_form': user_form})
Выдает ошибку здесь
if user_form.is_valid():