def sign_up(request): if request.method == 'POST': form = UserRegisterForm(request.POST) if form.is_valid(): form.save() messages.success(request, f'Your account has been created! You are now able to log in') return redirect('sign_in') else: form = UserRegisterForm() return render(request, 'home/sign_up.html', {'form': form})
def register(request): registered = False user_form = UserRegisterForm(request.POST) if request.method == 'POST': if user_form.is_valid(): amb = ambulance.objects.create( Name=user_form.cleaned_data.get('Name'), Address=user_form.cleaned_data.get('Address'), Contact=user_form.cleaned_data.get('Contact')) amb.save() request.session['id'] = amb.id return redirect('/') else: print(user_form.errors) else: user_form = UserRegisterForm() return render(request, 'ambulances.html', { 'form': user_form, 'registered': registered, 'value': 'Signup' })
def register(request): if request.method == 'POST': form = UserRegisterForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') messages.success(request, f'Account created successfully {username}!') return redirect('index') else: form = UserRegisterForm() return render(request, 'home/register.html', {'form': form})
def register(request): if request.method == 'POST': form = UserRegisterForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') messages.success( request, f'Your account has been created! You are now able to log in') current_user = User.objects.get(username=username) user_profile = Profile(user=current_user) user_profile.save() return redirect('login') else: form = UserRegisterForm() return render(request, 'profile/register.html', {'form': form})
def register(request): registered = False if request.method == "POST": user_form = UserRegisterForm(request.POST) if user_form.is_valid(): user = user_form.save() user.set_password(user.password) user.save() registered = True else: print(user_form.errors) else: user_form = UserRegisterForm() return render(request, 'auth/signup.html', { 'form': user_form, 'registered': registered, 'value': 'SignUp' })