Last active
December 31, 2015 18:39
-
-
Save victorono/8028349 to your computer and use it in GitHub Desktop.
middleware for display page when method is not allowed https://docs.djangoproject.com/en/1.2/topics/http/decorators/#allowed-http-methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from django.http import HttpResponseNotAllowed | |
from django.template import RequestContext | |
from django.template import loader | |
class HttpResponseNotAllowedMiddleware(object): | |
def process_response(self, request, response): | |
if isinstance(response, HttpResponseNotAllowed): | |
context = RequestContext(request) | |
response.content = loader.render_to_string("app/error_405.html", context_instance=context) | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment