When using Django REST Framework, the documentation mentions that the Http404 exception is intercepted and handled by DRF. However, when I try this in practice, I still get an HTML response from Django:
$ curl http://127.0.0.1:8000/foo
<h1>Not Found</h1><p>The requested URL /foo was not found on this server.</p>
Curiously, method-not-allowed exceptions are caught and turned into JSON correctly. Why isn't it working for 404s?
Edit: Appending -H 'Accept: application/json' also has no effect; the same HTML is still served.
view?Http404exception. By that logic, 404s should also be turned into JSON-formatted errors, no?