当前位置: 首页>>代码示例>>Python>>正文


Python forms.SigninForm类代码示例

本文整理汇总了Python中payments.forms.SigninForm的典型用法代码示例。如果您正苦于以下问题:Python SigninForm类的具体用法?Python SigninForm怎么用?Python SigninForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SigninForm类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sign_in

def sign_in(request):
    user = None
    if request.method == 'POST':
        form = SigninForm(request.POST)
        if form.is_valid():
            results = User.objects.filter(email=form.cleaned_data['email'])
            if len(results) == 1:
                if results[0].password == form.cleaned_data['password']:
                    request.session['user'] = results[0].id
                    return HttpResponseRedirect('/')
                else:
                  form.addError('Incorrect email address or password')
            else:
              form.addError('Incorrect email address or password')
    else:
      form = SigninForm()
      
    print form.non_field_errors()

    return render_to_response(
        'sign_in.html',
        {
          'form': form,
          'user': user
        },
        context_instance=RequestContext(request)
    )
开发者ID:Shaunwei,项目名称:django-rapidweb,代码行数:27,代码来源:views.py

示例2: sign_in

def sign_in(request):
    user = None
    #  checks if http request is POST
    if request.method == "POST":
        form = SigninForm(request.POST)
        #  form validation
        if form.is_valid():
            #  if form is valid, query database for the inputted email
            results = User.objects.filter(email=form.cleaned_data['email'])
            #  check query if query returns one result
            if len(results) == 1:
                #  check if the submitted password is the password
                if results[0].check_password(form.cleaned_data['password']):
                    #  creates a session
                    request.session['user'] = results[0].pk
                    return HttpResponseRedirect('/')
                else:
                    form.addError('Incorrect email address or password')
            else:
                form.addError('Incorrect email or password')
    else:
        form = SigninForm()

    print form.non_field_errors()

    return render_to_response(
        'sign_in.html',
        {
            'form': form,
            'user': user
        },
        context_instance=RequestContext(request)
    )
开发者ID:hooliooo,项目名称:django_ecommerce,代码行数:33,代码来源:views.py

示例3: sign_in

def sign_in(request):
    user = None
    if request.method == 'POST':
        form = SigninForm(request.POST)
        if form.is_valid():
            results = User.objects.filter(email=form.cleaned_data['email'])
            if len(results) == 1:
                if results[0].check_password(form.cleaned_data['password']):
                    request.session['user'] = results[0].pk
                    return redirect('/')
                else:
                    form.addError('Incorrect email address or password')
            else:
                form.addError('Incorrect email address or password')
    else:
        form = SigninForm()

    print(form.non_field_errors())

    return render(
        request,
        'sign_in.html',
        {
            'form': form,
            'user': user
        }
    )
开发者ID:Pac23,项目名称:book2-exercises,代码行数:27,代码来源:views.py

示例4: sign_in

def sign_in(request):
    user = None

    if request.method == 'POST':
        form = SigninForm(request.POST)
        if form.is_valid():
            result = User.objects.filter(email=form.cleaned_data['email'])
            if len(result) == 1:
                if result[0].check_password(form.cleaned_data['password']):
                    request.session['user'] = result[0].pk
                    return HttpResponseRedirect('/')
                else:
                    form.addError("Incorect email or password")
            else:
                form.addError("Incorect email or password")
    else:
        form = SigninForm()

    print((form.non_field_errors()))

    return render_to_response(
        'payments/sign_in.html',
        {
            'form':form,
            'user':user
        },
        context_instance=RequestContext(request)
    )
开发者ID:SValchev,项目名称:Encomerce,代码行数:28,代码来源:views.py

示例5: sign_in

def sign_in(request):
    user = None
    if request.method == "POST":
        form = SigninForm(request.POST)
        if form.is_valid():
            results = User.objects.filter(email=form.cleaned_data["email"])
            if len(results) == 1:
                if results[0].check_password(form.cleaned_data["password"]):
                    request.session["user"] = results[0].pk
                    return HttpResponseRedirect("/")
            else:
                form.addError("Incorrect email address or password")
        else:
            form.addError("Incorrect email address or password")
    else:
        form = SigninForm()

    print form.non_field_errors()

    return render_to_response("sign_in.html", {"form": form, "user": user}, context_instance=RequestContext(request))
开发者ID:hnejadi,项目名称:django-ecommerce-8,代码行数:20,代码来源:views.py


注:本文中的payments.forms.SigninForm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。