我有一个名为的视图Scan
,它采用模型形式input and
将其发送到另一个视图Processscan
,该视图应该input
从Scan
视图中获取值并在视图中处理它Processscan
。
目前,Processscan
正在从视图中获取输入Scan
并输出值,但不会越界:
return HttpResponse("We got to the processor with domain: " + EnteredDomain)
Process
视图看起来像:
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
})
Processscan
视图看起来像:
def Processscan(request):
# mechanize setup
harvest = mechanize.Browser()
harvest.addheaders = settings.MECHANIZE_USER_AGENT_HARVESTING
EnteredDomain = request.GET.get('domainNm')
return HttpResponse("We got to the processor with domain: " + EnteredDomain)
mechanizeBrowser = mechanize.Browser
mechanizeBrowser.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
r=mechanizeBrowser.open('http://www.thedomain.com')
output = r.read()
print output
目前,输出在这里停止,当它应该继续时Processscan
:
return HttpResponse("We got to the processor with domain: " + EnteredDomain)
知道出了什么问题吗?