【发布时间】:2013-08-08 04:58:42
【问题描述】:
def Scan(request):
form = SubmitDomain(request.POST or None) # A form bound to the POST data
if request.method == 'POST': # If the form has been submitted...
if form.is_valid(): # If form input passes initial validation...
domainNmCleaned = form.cleaned_data['domainNm'] ## clean data in dictionary
form.save() #save cleaned data to the db from dictionary
try:
return HttpResponseRedirect('/Processscan/?domainNm=' + domainNmCleaned)
except:
raise ValidationError(('Invalid request'), code='invalid') ## [ TODO ]: add a custom error page here.
else:
form = SubmitDomain()
return render(request, 'VA/index.html', {
'form' : form
})
def Processscan(request):
EnteredDomain = request.get('domainNm', '')
return HttpResponse("We got to the processor with domain: " + EnteredDomain)
请放轻松-我还在学习:)
我现在在使用 POST 时遇到 GET 问题,在我最初请求域名时 - 我得到:
'WSGIRequest' object has no attribute 'get'
开:
EnteredDomain = request.get('domainNm', '')
【问题讨论】:
标签: django forms post redirect django-forms