def process_health_case(request):
about = request.POST['about']
details = request.POST['narrative_text']
image=request.FILES['image_scan']
connection = Connection('mongodb://sbose78:PASSWORD@staff.mongohq.com:10068/BOSE')
if images:
db=connection['BOSE']
fs=gridfs.GridFS(db)
fs.put(image,filename="image_scan2")
else:
#nothing
return render_to_response('home/new_narrative.html',{ }, context_instance=RequestContext(request))
我得到了
expected an indented block (views.py, line 41)
第 41 行是最后一行。
我哪里错了?
谢谢。
最佳答案
您不能将评论用作空语句,您应该使用 pass
如果你想要一个什么都不做的显式 else。
if images:
db=connection['BOSE']
fs=gridfs.GridFS(db)
fs.put(image,filename="image_scan2")
else:
pass
return ....
由于没有声明,所以在 else
中发表评论在你的代码中,python 认为 return
应该是else
的内容并给出意图错误。
关于Python 缩进问题 : Expected an indentation block,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12328709/