即使对象在db中,我也会收到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个错误。答案 0 :(得分:1)
你真的需要学习阅读错误追溯。很明显,错误来自对|random
模板过滤器的调用。也许你传递的是一个空值。