Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dmitry-naumenko/efe509e167c5b595092706abc3f564c6 to your computer and use it in GitHub Desktop.
Save dmitry-naumenko/efe509e167c5b595092706abc3f564c6 to your computer and use it in GitHub Desktop.
from django.http import Http404
def check_user_able_to_see_page(*groups):
def decorator(function):
def wrapper(request, *args, **kwargs):
if request.user.groups.filter(name__in=groups).exists():
return function(request, *args, **kwargs)
raise Http404
return wrapper
return decorator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment