[Django]-Django REST Framework does not intercept 404 exceptions and outputs HTML instead of JSON

3๐Ÿ‘

โœ…

I think this is simple logic that, the Method Not Allowed exception is related to a view which is defined using DRF. That means the exception raises when the request is reached at some view (DRF-View).

The Page Not Found exception raises at URL Dispatcher if the input URL is not matched with defined URLs and hence it calls the 404 (page not found) view . But also, DRF handles HTTP 404 Not Found when we try to get the details of an instance (api/some_endpoint/instance_id/) and it not found in DB

Reference:
The 404 (page not found) view

๐Ÿ‘คJPG

Leave a comment