本文整理匯總了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))