{"id":41754,"date":"2023-12-11T14:54:29","date_gmt":"2023-12-11T06:54:29","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=41754"},"modified":"2023-12-11T14:54:29","modified_gmt":"2023-12-11T06:54:29","slug":"%e4%bb%80%e4%b9%88%e6%98%af%e6%96%ad%e8%a8%80%ef%bc%9f%e5%ba%94%e7%94%a8%e5%9c%ba%e6%99%af%ef%bc%9f","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/12\/11\/%e4%bb%80%e4%b9%88%e6%98%af%e6%96%ad%e8%a8%80%ef%bc%9f%e5%ba%94%e7%94%a8%e5%9c%ba%e6%99%af%ef%bc%9f\/","title":{"rendered":"\u4ec0\u4e48\u662f\u65ad\u8a00\uff1f\u5e94\u7528\u573a\u666f\uff1f"},"content":{"rendered":"<p>&#8220;`&#8221;<\/p>\n<pre><code>assert \u662f\u7684\u4f5c\u7528\uff1f\u65ad\u8a00\n\u6761\u4ef6\u6210\u7acb\uff08\u5e03\u5c14\u503c\u4e3aTrue\uff09\u5219\u7ee7\u7eed\u5f80\u4e0b\uff0c\u5426\u5219\u8dd1\u51fa\u5f02\u5e38\uff0c\u4e00\u822c\u7528\u4e8e\uff1a\u6ee1\u8db3\u67d0\u4e2a\u6761\u4ef6\u4e4b\u540e\uff0c\u624d\u80fd\u6267\u884c\uff0c\u5426\u5219\u5e94\u8be5\u8dd1\u51fa\u5f02\u5e38\u3002\n\n\u5199API\u7684\u65f6\u5019\uff0c\u7ee7\u627fGenericAPIView\n\nclass GenericAPIView(views.APIView):\n                    \"\"\"\"\"\"\n                    Base class for all other generic views.\n                    \"\"\"\"\"\"\n                    # You'll need to either set these attributes,\n                    # or override `get_queryset()`\/`get_serializer_class()`.\n                    # If you are overriding a view method, it is important that you call\n                    # `get_queryset()` instead of accessing the `queryset` property directly,\n                    # as `queryset` will get evaluated only once, and those results are cached\n                    # for all subsequent requests.\n                    queryset = None\n                    serializer_class = None\n\n                    # If you want to use object lookups other than pk, set 'lookup_field'.\n                    # For more complex lookup requirements override `get_object()`.\n                    lookup_field = 'pk'\n                    lookup_url_kwarg = None\n\n                    # The filter backend classes to use for queryset filtering\n                    filter_backends = api_settings.DEFAULT_FILTER_BACKENDS\n\n                    # The style to use for queryset pagination.\n                    pagination_class = api_settings.DEFAULT_PAGINATION_CLASS\n\n                    def get_queryset(self):\n\n                        assert self.queryset is not None, (\n                            \"\"'%s' should either include a `queryset` attribute, \"\"\n                            \"\"or override the `get_queryset()` method.\"\"\n                            % self.__class__.__name__\n                        )\n\n                        queryset = self.queryset\n                        if isinstance(queryset, QuerySet):\n                            # Ensure queryset is re-evaluated on each request.\n                            queryset = queryset.all(\n                        return queryset\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<pre><code>            \"```\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;`&#8221; assert \u662f\u7684\u4f5c\u7528\uff1f\u65ad\u8a00 \u6761\u4ef6\u6210\u7acb\uff08\u5e03\u5c14\u503c\u4e3aTrue\uff09\u5219\u7ee7\u7eed\u5f80\u4e0b\uff0c\u5426\u5219\u8dd1\u51fa [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-41754","post","type-post","status-publish","format-standard","hentry","category-c"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/41754","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=41754"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/41754\/revisions"}],"predecessor-version":[{"id":41755,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/41754\/revisions\/41755"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=41754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=41754"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=41754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}