即使对象在数据库中,我也会收到 500 错误。错误是:
IndexError: string index out of range
错误行是:
location = Location.objects.get(id=lid)
return render_to_response('location.html',{'location':location},context_instance=RequestContext(request))
这是整个视图功能:
def location(request,locname,lid):
try:
location = Location.objects.get(id=lid)
return render_to_response('location.html',{'location':location},context_instance=RequestContext(request))
except Location.DoesNotExist:
return render_to_response('404.html',{},context_instance=RequestContext(request))
这是错误回溯: http: //pastebin.com/v0ACzRBj
我究竟做错了什么?问题是相同形式的其他位置很好。我可以打开他们的个人资料,但只有两个位置的个人资料给出 500 错误。