Skip to content

Instantly share code, notes, and snippets.

@jsocol
Created June 13, 2012 17:30
Show Gist options
  • Select an option

  • Save jsocol/2925392 to your computer and use it in GitHub Desktop.

Select an option

Save jsocol/2925392 to your computer and use it in GitHub Desktop.
BannedSession
class BannedSession(Exception):
"""For various reasons, mostly in get_response, I don't think you
want to inherit from PermissionDenied."""
pass
class BannedMiddleware(object):
def process_exception(self, request, exception):
if isinstance(exception, BannedException):
return render(request, 'banned.html', {'reason': exception.args[0]})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment