class ShortCircuitMiddleware(object):
    """ Middleware; looks for a view function named '_shortcircuitmiddleware'
    and short-circuits. Relies on the fact that if you return an HttpResponse
    from a view, it will short-circuit other middleware, see:
    https://docs.djangoproject.com/en/dev/topics/http/middleware/
     """

def process_view(self, request, view_func, view_args, view_kwargs):
    if view_func.__name__ == '_shortcircuitmiddleware':
        return view_func(request, *view_args, **view_kwargs)
return None
Неглобальное промежуточное ПО в Django