我的views.py中有以下内容
我一直在阅读文档并试图找出是否有办法排除此视图的某些端点。
from EoX.models import Vendor
from rest_framework import viewsets
from rest_framework import permissions
from .serializers import VendorSerializer
from url_filter.integrations.drf import DjangoFilterBackend
from drf_yasg.utils import swagger_auto_schema
from django.utils.decorators import method_decorator
class VendorViewSet(viewsets.ModelViewSet):
queryset = Vendor.objects.all()
serializer_class = VendorSerializer
permission_classes = [permissions.AllowAny]
filter_backends = [DjangoFilterBackend]
filter_fields = ['name',]
我可以将视图全部排除在外
schema=None
我试着用
@method_decorator(name='list', decorator=swagger_auto_schema(
operation_description="description from swagger_auto_schema via method_decorator"
))
这会改变“get”端点的描述。
但尝试
@method_decorator(name='list', decorator=swagger_auto_schema(methods=['get'],
operation_description="description from swagger_auto_schema via method_decorator"
))
抛出错误
AssertionError:
方法or
方法can only be specified on @action or @api_view views
这是一个错误吗?或者只是不支持的功能,有没有办法完成我正在尝试的事情?
非常感谢。