0

我有几个视图集继承viewsets.ViewSet并包含覆盖list()方法。我已经在 API 页面上注册了所有这些视图集。

现在我还有一个视图集可以覆盖update(),但我无法在 API 页面上看到它。

这是我的代码:

class ReadNotificationsAPI(viewsets.ViewSet):
"""
   Custom API for to mark notifications as read by recipient
"""
permission_classes = (IsAuthenticated,)

def update(self, request, pk=None):
    # some operations
    response_obj = {'response': 'success'}
    return Response(response_obj, status=status.HTTP_200_OK)

进入路由器:

router.register(r'readnotificationsapi', notification_views.ReadNotificationsAPI, 'readnotificationsapi')

其他只有list()在 API 页面上可见的自定义视图,但不是这个。有什么帮助吗?

4

0 回答 0