What’s the difference between returning a `HttpResponseNotFound` and raising a `Http404` in Django?

An HttpResponseNotFound is just like a normal HttpResponse except it sends error code 404. So it’s up to you to render an appropriate 404 page in that view, otherwise the browser will display its own default.

Raising an Http404 exception will trigger Django to call its own 404 error view. Actually, this does little more than render the 404.html template and send it – using HttpResponseNotFound, in fact. But the convenience is that you’re then specifying the template (and view, if you like) in one place.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)