我所犯的错误:
视图report.views.csv_gen_universal没有返回HttpResponse对象。
def csv_gen_universal(req):
if req.POST['csvinputid']:
# Create the HttpResponse object with the appropriate CSV header.
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] ='attachment;filename="M_Wall_report.csv"'
writer = csv.writer(response)
content = str(req.POST['csvinputid']).split("^~^")
for m in content :
p = m.split("*~*")
writer.writerow(p)
return response
else:
HttpResponse("Wrong Place")发布于 2015-06-24 06:35:08
忘记在else语句中添加return。你的代码应该是
def csv_gen_universal(req):
if req.POST['csvinputid']:
# Create the HttpResponse object with the appropriate CSV header.
response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] ='attachment;filename="M_Wall_report.csv"'
writer = csv.writer(response)
content = str(req.POST['csvinputid']).split("^~^")
for m in content :
p = m.split("*~*")
writer.writerow(p)
return response
else:
return HttpResponse("Wrong Place")https://stackoverflow.com/questions/31019179
复制相似问题