我们应该从哪里打django的第三方api?

我是django的初学者。所以我目前的结构是

--/project
----/settings.py
----/urls.py
----/wsgi.py
--/app1
----/migrations
----/admin.py
----/apps.py
----/models.py
--/app2
----/migrations
----/serializers.py
----/apps.py
----/urls.py
----/views.py

我想知道我应该在什么地方以及如何(访问)编写一些东西:

  1. 我想通过点击他们的API并获取我需要的数据来与第三方存储服务建立联系。
  2. 我想将这些数据存储在我在models.py中创建的某个模型中的数据库中。让我们说“设置”
  3. 我想使用“设置数据”生成更多数据并将其存储在数据库中以供其他模型(例如“商品”)使用
  4. 最后,项目是我已经实现的应用程序其余api在响应中发送的内容。

现在,我正在击打views.py中的第三方api,如下所示:

class ItemViewSet(viewsets.ModelViewSet):
    queryset = Item.objects.all()
    serializer_class = serializers.ItemSerializer
    authentication_classes = (TokenAuthentication,)
    permission_classes = (IsAuthenticated,)

    def get_queryset(self):
        return self.queryset.order_by('order_id')

    def perform_create(self,serializer):
        """Create a new Item"""
        # generate some auth string and hit api
        # http = urllib3.PoolManager()
        # response_auth = http.request(
        #     'GET',#     SOME_URL,#     headers={auth: auth_string},# )
        # print(response_auth.status)
        # print(response_auth.data)
        # auth_response = json.loads(response_auth.data.decode('utf8'))
        # print(auth_response)
        # serializer.save(user=self.request.user,name=auth_response['name'])

我正在从管理站点获取Item的其他一些字段。还有一些来自api。

meachol 回答:我们应该从哪里打django的第三方api?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3136267.html

大家都在问