def signupview(request): form=SignUpForm() if request.method=='POST': form=SignUpForm(request.POST) user=form.save() user.set_password(user.password) user.save() return HttpResponseRedirect('/accounts/login') return render(request,'store/signup.html',{'form':form})
def signUpView(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): # save user form.save() # get username from form username = form.cleaned_data.get('username') # get user from db signUpUser = User.objects.get(username=username) # group customer_group = Group.objects.get(name="Customer") # assign group customer_group.user_set.add(signUpUser) else: form = SignUpForm return render(request, "signup.html", {'form': form})
def signupView(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data.get('username') signup_user = User.objects.get(username=username) customer_group = Group.objects.get(name='Customer') customer_group.user_set.add(signup_user) else: form = SignUpForm() return render(request, 'signup.html', context={'form': form})
def signUpView(request): if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): #บันทึกข้อมูล User form.save() #บันทึก Group Customer #ดึง username จากแบบฟอร์มมาใช้ username = form.cleaned_data.get('username') #ดึงข้อมูล user จากฐานข้อมูล signUpUser = User.objects.get(username=username) #จัด Group customer_group = Group.objects.get(name="Customer") customer_group.user_set.add(signUpUser) else: form = SignUpForm() return render(request, "signup.html", {'form': form})
def signUpView(request): if request.method == "POST": form = SignUpForm(request.POST) #เช็คความถูกต้องของ แบบฟอร์ม if form.is_valid(): #บันทึกข้อมูล user form.save() #บันทึกกลุ่มข้อมูล ของ user #ดึง username จาก form เอามาใช้ #เช็คความถูกต้อง username = form.cleaned_data.get('username') #ดึงข้อมูล user จากฐานข้อมูล signUpUser = User.objects.get(username=username) #จัดกลุ่ม user customer_group = Group.objects.get(name="Customer") customer_group.user_set.add(signUpUser) else: form = SignUpForm() return render(request,'signup.html',{'form':form})
def sign_up(request): if request.POST: form = SignUpForm(request.POST) if form.is_valid(): user = form.save() user.refresh_from_db() password = form.cleaned_data.get('password1') username = form.cleaned_data.get('username') user = authenticate( username=username, password=password, ) login(request, user) return redirect('buy') errors = form.errors return render(request, 'store/register.html', {'form': SignUpForm(request.POST)}) return render(request, 'store/register.html', {'form': SignUpForm()})