本文整理汇总了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)
)
示例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)
)
示例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
}
)
示例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)
)
示例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))