1 from django.http import HttpResponse
2 from django.utils.decorators import decorator_from_middleware
4 from philo.contrib.penfield.exceptions import HttpNotAcceptable
7 class HttpNotAcceptableMiddleware(object):
8 """Middleware to catch HttpNotAcceptable errors and return an Http406 response.
10 def process_exception(self, request, exception):
11 if isinstance(exception, HttpNotAcceptable):
12 return HttpResponse(status=406)
15 http_not_acceptable = decorator_from_middleware(HttpNotAcceptableMiddleware)