def post(self, request, *args, **kwargs): 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('dashboard')
def post(self, request, *args, **kwargs): form = SignUpForm(self.request.POST) if form.is_valid(): user = form.save() user.refresh_from_db() password = form.cleaned_data.get('password1') user = authenticate(username=user.username, password=password) login(self.request, user) return redirect('home') return self.render_to_response({'form': form})
def register_user(request): msg = None success = False 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) msg = 'User created.' success = True # return redirect("/login/") else: msg = 'Form is not valid' else: form = SignUpForm() return render(request, "accounts/register.html", { "form": form, "msg": msg, "success": success })
def register(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): userObj = form.cleaned_data username = userObj['username'] email = userObj['email'] password = userObj['password'] if (User.objects.filter(username=username).exists()) or User.objects.filter(email=email).exists(): return redirect("/signup/?add_unique_username=true") else: User.objects.create_user(username, email, password) user = authenticate(username=username, email=email, password=password) login(request, user) return redirect('/index/') else: print("Form not valid") render(request, 'register.html', {'form': form}) else: form = SignUpForm() return render(request, 'register.html', {'form': form}) print("ELSE OR IF STATEMENT NOT EXECUTED")
def signup_view(request): now_time=datetime.now() if request.method=="POST": form=SignUpForm(request.POST) if form.is_valid(): username=form.cleaned_data['username'] name=form.cleaned_data['name'] email=form.cleaned_data['email'] password=form.cleaned_data['password'] #encrpyt the password password=make_password(password) #saving data to DB user=UserModel(name=name,username=username,email=email,password=password) user.save() return render(request,'success.html') else: form=SignUpForm() return render(request,'signUp.html',{'now':now_time,'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('/dashboard/') else: form = SignUpForm() return render(request, 'override_signup.html', {'form': form})
def get_context_data(self, **kwargs): context = super(SignUpView, self).get_context_data(**kwargs) context['form'] = SignUpForm() return context
def get(self, request, *args, **kwargs): form = SignUpForm() return render(request, self.template_name, self.get_context_data(form=form, active_link='signup'))