2
In your case 405 HTTP error is returned.
You could try to create middleware
for custom errors:
from django.http import HttpResponseNotAllowed
class CustomHTTPErrorsMiddleware(object):
def process_response(self, request, response):
if isinstance(response, HttpResponseNotAllowed):
# Custom response for `HttpResponseNotAllowed`.
pass
return response
Also, Django’s error handling may be useful.
Source:stackexchange.com