When i read Django documentation i found only handlers for: 400, 403, 404, 500 errors.
Why 405 error handler doesn't exists but decorators like require_POST() is in common use?
The point is, what is proper way to create custom error page for Method Not Allowed error ?
I resolve my problem using Django Middleware maybe this will help someone
from django.http import HttpResponseNotAllowed
from django.shortcuts import render
class HttpResponseNotAllowedMiddleware:
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
response = self.get_response(request)
if isinstance(response, HttpResponseNotAllowed):
return render(request, '405.html', status=405)
return response