Skip to content

Instantly share code, notes, and snippets.

@sankalpjonn
Last active March 21, 2021 01:06
Show Gist options
  • Select an option

  • Save sankalpjonn/1ac4b2109b17911330b4242220bc906c to your computer and use it in GitHub Desktop.

Select an option

Save sankalpjonn/1ac4b2109b17911330b4242220bc906c to your computer and use it in GitHub Desktop.
from rest_framework.views import APIView
from .custom_permissions import IsAdmin, IsEditor, IsUser
# only admins are allowed to access this view
class APIView1(APIView):
permission_classes = (IsAdmin,)
# Admins or editors are allowed to access this view
class APIView2(APIView):
permission_classes = (IsAdmin | IsEditor,)
# all types of users are allowed to access this view
class APIView3(APIView):
permission_classes = (IsAdmin | IsEditor | IsUser,)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment