I am learning Django Rest Framework, and also new to django. I want to return a custom 404
error in json when a client will access a resource which was not found.
My urls.py
looks liks this:
urlpatterns = [
url(r'^mailer/$', views.Mailer.as_view(), name='send-email-to-admin')
]
In which i have only one resource, which can be accessed through URI, http://localhost:8000/mailer/
Now, when a client access any other URI like http://localhost:8000/, API should return a 404-Not Found
error like this:
{
"status_code" : 404
"error" : "The resource was not found"
}
Please suggest some answer with proper code snippets, if suitable.