나는이 간단한보기 기능이 있습니다IndexError : 문자열 인덱스가 범위를 벗어났습니다. - 장고 - 왜?
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)) #<-- error line
을하지만 난 단지 프로덕션 서버에 IndexError: string index out of range
을 얻고있다.
오류 줄이 마지막 줄에 있습니다.
내가 뭘 잘못하고 있니?
안녕하세요, Brandon, 감사합니다. 이보다 시원하게 보입니다. render_to_response와 context_instance의 차이점은 무엇입니까? – doniyor
이것이 더 좋은 방법이지만 오류가 발생하는 이유를 설명하지 않습니다. – hellsgate
render가 자동으로 컨텍스트 인스턴스를 만듭니다. – Brandon