コード例 #1
0
def signin(request):
    if request.method == 'GET':
        return render(request, 'front_signin.html')
    else:
        form = SigninForm(request.POST)
        print form.is_valid()
        if form.is_valid():
            email = form.cleaned_data.get('email')
            password = form.cleaned_data.get('password')
            user = login(request, email, password)
            if user:
                remember = form.cleaned_data.get('remember')
                if remember:
                    request.session.set_expiry(None)
                else:
                    request.session.set_expiry(0)
                nexturl = request.GET.get('next')
                print nexturl
                if nexturl:
                    return redirect(nexturl)
                else:
                    return redirect(reverse('front_index'))
            else:
                return render(request, 'front_signin.html',
                              {'error': u'用户名和密码错误'})
        else:
            return render(request, 'front_signin.html',
                          {'error': form.get_error()})
コード例 #2
0
ファイル: views_m.py プロジェクト: maloneguo/ldj17
def signin(request):
    if request.method == "POST":
        form = SigninForm(request.POST)
        if form.is_valid():
            form.save()
            newUser=authenticate(username=form.cleaned_data["username"],
                                 password=form.cleaned_data["password1"])
            authlogin(request, newUser)
            return HttpResponseRedirect("/")
    else :
        form  = SigninForm()
    data={
        "form":form,
    }
    return render(request,"blog/mobile/registration/signin.html",data)
コード例 #3
0
ファイル: views.py プロジェクト: bazzard72/country02
def signin(request):
    context = {}
    context['form'] = SigninForm()

    if request.method == 'POST':
        form = SigninForm(request.POST)
        context['form'] == form
        if form.is_valid():
            username = form.cleaned_data['username']
            password = form.cleaned_data['password']
            try:
                auth_user = authenticate(username=username, password=password)

                login(request, auth_user)

                return redirect('/countrylist/')

            except Exception, e:

                return HttpResponse(
                    'Wrong USERNAME or PASSWORD! Please <a href="/signin/">Try Again </a>'
                )