def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() return redirect('/polls') else: form = SignUpForm() args = {'form': form} return render(request, 'polls/signup_form.html', args)
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): user = form.save() user.refresh_from_db() user.profile.primeiro_nome = form.cleaned_data.get('primeiro_nome') user.save() user.profile.ultimo_nome = form.cleaned_data.get('ultimo_nome') user.save() #user.profile.ID = form.cleaned_data.get('ID') #user.save() user.profile.email = form.cleaned_data.get('email') user.save() #user.User.password = form.cleaned_data.get('password') #user.save() user.profile.telefone = form.cleaned_data.get('telefone') user.save() user.profile.nome_aparelho = form.cleaned_data.get('nome_aparelho') user.save() raw_password = form.cleaned_data.get('password1') user = authenticate(username=user.username,password=raw_password) login(request,user) return redirect('minhaconta') else: form = SignUpForm() return render (request, 'signup.html', {'form':form})
def signup(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(username=username, password=raw_password) login(request, user) return redirect('/') else: return render(request, 'user_register.html', {'form': form}) else: cat = Category.objects.all form = SignUpForm() return render(request, 'user_register.html', { 'form': form, 'category': cat })
def signup(request): global logged_in, user if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() first_name = form.cleaned_data.get('first_name') last_name = form.cleaned_data.get('last_name') username = form.cleaned_data.get('username') raw_password = form.cleaned_data.get('password1') user = authenticate(first_name=first_name, last_name=last_name, username=username, password=raw_password) logged_in = True login(request, user) return redirect('home') else: error = "" if 'password2' in form.errors.as_data(): error = list(form.errors.as_data()['password2'][0])[0] elif 'username' in form.errors.as_data(): error = list(form.errors.as_data()['username'][0])[0] return render(request, 'signup.html', {'form': form, 'logged_in': logged_in, 'error': error}) else: form = SignUpForm() return render(request, 'signup.html', {'form': form, 'logged_in': logged_in, 'error': "nothing"})