DRF APIVIEW only post method permisiion_classes
You can set permission classes for a DRF APIView's POST method by adding the permission_classes attribute to the class definition and setting it to a list of permission classes. For example:
from rest_framework.views import APIView
from rest_framework.permissions import IsAuthenticated
class MyAPIView(APIView):
permission_classes = [IsAuthenticated]
def post(self, request):
# POST method logic here
pass
In this example, only authenticated users will be able to access the post method of the MyAPIView class.
原文地址: https://www.cveoy.top/t/topic/5QR 著作权归作者所有。请勿转载和采集!