我从 def start 方法开始,它调用 go_adder 在 adder.html 中将 num 值相加 5 次,直到 num 等于 5。之后,adder 方法应该返回 ready=1
在views.py
def start(request):
num=0
ready_or_not=go_adder(num)
return HttpResponse("Ready: %s "%str(ready_or_not))
def go_adder(num):
ready=0
if num<5:
return render_to_response('adder.html',{'num':num})
elif num==5:
ready=1
return ready
def check_post(request,num):
if request.method == 'POST':
num+=1
return adder(num)
当我尝试运行此代码段时,它一直有效,直到我的“num = 5”,然后我得到那个错误:
'int' object has no attribute 'status_code'
Exception Location: C:\Python27\lib\site-packages\django\middleware\common.py in process_response, line 94
和 Traceback 说:
C:\Python27\lib\site-packages\django\core\handlers\base.py in get_response
response = middleware_method(request, response) ...
▶ Local vars
C:\Python27\lib\site-packages\django\middleware\common.py in process_response
if response.status_code == 404: ...
▶ Local vars
我该如何解决这个错误?请你帮助我好吗 ?