120👍
✅
Took me a while to figure out,
Eventually I had to raise
the Http404
and not return
it!
11👍
return Http404() ==> is a wrong
raise Http404() ==> is a correct
((under _ example code))
def room_detail(request, pk):
try:
room = models.Room.objects.get(pk=pk)
return render(request, "rooms/detail.html", {"room": room})
except models.Room.DoesNotExist:
raiseHttp404()
- [Django]-Simple guestbook django: __init__() takes 1 positional argument but 2 were given
- [Django]-What's the difference between staff, admin, superuser in django?
- [Django]-From virtualenv, pip freeze > requirements.txt give TONES of garbage! How to trim it out?
Source:stackexchange.com