Exception Type: AttributeError
错误提示: type object 'Person' has no attribute 'DoesNoExist' Request Method: GET Request URL: http://127.0.0.1:8000/app1/person_detail/7 Django Version: 2.0 Exception Type: AttributeError Exception Value: type object 'Person' has no attribute 'DoesNoExist'
源码: def person_detail(request, pk): try: p = Person.objects.get(pk=pk) except Person.DoesNoExist: raise Http404('Person Does Not Exit') return render(request, 'person_detail.html', {'person':p})
引入对象模型: from django.http import HttpResponse, HttpResponseRedirect, Http404 from app1.models import Person
尝试引入: from django.core.exceptions import ObjectDoesNotExist 没法解决
有没有大神们遇到过类似问题,请问大神们怎么解决该问题?
评论 0