Django rest framework 如何在DRF中获取post数据?

Django rest framework 如何在DRF中获取post数据?,django-rest-framework,Django Rest Framework,我正试图从api中获取post信息,在获取信息后,我想在django rest框架中使用令牌身份验证调用一个api,其中包含以下信息。我已经看到stackoverflow中有一些soln,但在这里什么都不起作用。这是我的密码: class DataInsertViewSet(generics.ListAPIView): authentication_classes = (authentication.TokenAuthentication,) permission_classes

我正试图从api中获取post信息,在获取信息后,我想在django rest框架中使用令牌身份验证调用一个api,其中包含以下信息。我已经看到stackoverflow中有一些soln,但在这里什么都不起作用。这是我的密码:

class DataInsertViewSet(generics.ListAPIView):
    authentication_classes = (authentication.TokenAuthentication,)
    permission_classes = (permissions.IsAuthenticated,)

    def post(self, request, *args, **kwargs):
        post_data = request.data
        # HERE I WILL CALL API
        return Response(data=post_data , status=status.HTTP_200_OK)
但是当我运行api时,我得到了一个错误

Internal Server Error: /api/insertData
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
TypeError: __init__() takes 1 positional argument but 2 were given

我不太清楚我在这里做错了什么。任何建议都会大有帮助!!提前感谢

我认为此错误不是来自视图,请提供完整的trackback错误。在urlspatterns.py中,我忘记添加as_view()。但是现在我遇到另一个错误,
'DataInsertViewSet'应该包含一个
queryset`属性,或者覆盖
get\u queryset()
方法。我应该如何克服您必须使用queryset=“model\u name”包含model的缺点,除非model、view不能工作。