예제 #1
0
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})
예제 #2
0
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})
예제 #3
0
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})
예제 #4
0
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})
예제 #5
0
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})
예제 #6
0
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()})