Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swagger不能正确反映Django Rest框架中的POST端点定义_Django_Django Rest Framework_Swagger - Fatal编程技术网

Swagger不能正确反映Django Rest框架中的POST端点定义

Swagger不能正确反映Django Rest框架中的POST端点定义,django,django-rest-framework,swagger,Django,Django Rest Framework,Swagger,我有一个小问题 class SmallEndpointViewSet(APIView): def post(self, request, *args, **kwargs): //add the request.data data to the db def delete(self, request, pk, format=None): // remove the data[pk] from db 在URL.py中 urlpatterns = [

我有一个小问题

class SmallEndpointViewSet(APIView):

    def post(self, request, *args, **kwargs):
        //add the request.data data to the db

    def delete(self, request, pk, format=None):
       // remove the data[pk] from db
在URL.py中

urlpatterns = [
 url(
        r'^small-endpoint/(?P<pk>\d+)/$',
        mystuff_views.SmallEndpointViewSet.as_view(),
        name='small-endpoint'
    ),
    url(
        r'^small-endpoint/$',
        mystuff_views.SmallEndpointViewSet.as_view(),
        name='small-endpoint'
    ),
]
但随后我收到错误TypeError:as_view()正好接受1个参数(给定2个)

我相信as_view的APIView版本不接收参数,这很好。我真正想要的是大摇大摆地正确地反映出POST调用不需要和id

我该怎么做

url(
            r'^small-endpoint/$',
            mystuff_views.SmallEndpointViewSet.as_view({
            'post': 'create'
        }),
            name='small-endpoint'
        ),