Skip to content

Instantly share code, notes, and snippets.

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

  • Save sankalpjonn/6ae2f980480e174cb59944bf73f5224d to your computer and use it in GitHub Desktop.

Select an option

Save sankalpjonn/6ae2f980480e174cb59944bf73f5224d to your computer and use it in GitHub Desktop.
from rest_framework.authentication import TokenAuthentication
from rest_framework.views import APIView
class BaseView(APIView):
authentication_classes = [
TokenAuthentication,
]
class MyAuthenticatedView(BaseView):
# This view will automatically apply TokenAuthentication
def get(self, request):
pass
def post(self, request):
pass
class MyNonAuthenticatedView(APIView):
# This view will not be authenticated
def get(self, request):
pass
def post(self, request):
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment