本文整理汇总了Python中forms.Form.is_valid方法的典型用法代码示例。如果您正苦于以下问题:Python Form.is_valid方法的具体用法?Python Form.is_valid怎么用?Python Form.is_valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.Form
的用法示例。
在下文中一共展示了Form.is_valid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: form
# 需要导入模块: from forms import Form [as 别名]
# 或者: from forms.Form import is_valid [as 别名]
def form(request):
if request.method == 'POST':
form = Form(request.POST)
if form.is_valid():
return render_to_response('form.html',{'m':'woo hoo'})
else:
form = Form()
return render_to_response('form.html', {
'form': form,
})
示例2: skriv
# 需要导入模块: from forms import Form [as 别名]
# 或者: from forms.Form import is_valid [as 别名]
def skriv(request):
data = {}
if request.method == "POST":
form = Form(data=request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect(reverse('gastbok'))
else:
form = Form(initial={'spamcheck': 'Sto'})
data['form'] = form
return render(request, 'guestbook/skriv.html', data)
示例3: diff
# 需要导入模块: from forms import Form [as 别名]
# 或者: from forms.Form import is_valid [as 别名]
def diff(request):
base_result = ''
new_result = ''
if request.method == 'POST':
form = Form(request.POST)
if form.is_valid():
base_url = form.cleaned_data['base_url']
new_url = form.cleaned_data['new_url']
query = form.cleaned_data['query']
if base_url != '' and new_url != '' and query != '':
base_result = urllib2.urlopen("%s%s" % (base_url.encode('utf8'), query.encode('utf8'))).read()
if base_result != '':
base_result = simplejson.loads(base_result)['records']
new_result = urllib2.urlopen("%s%s" % (new_url.encode('utf8'), query.encode('utf8'))).read()
if new_result != '':
new_result = simplejson.loads(new_result)['records']
print base_result
else:
form = Form()
return render_to_response('diff.html', {'form': form, 'base_result': base_result, 'new_result': new_result}, context_instance=RequestContext(request))