class MyGoneMiddleware(object):

    def process_exception(self, request, exception):
        if isinstance(exception, Http410):
            return HttpResponseGone('Gone!')
How to raise a 410 error in Django