Last active
March 21, 2021 01:05
-
-
Save sankalpjonn/6ae2f980480e174cb59944bf73f5224d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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