Django Rest Framework,允许:POST未在通用视图中设置

时间:2018-06-07 20:49:01

标签: python django django-rest-framework

我有一个继承Allow的DRF通用视图,但POST标头不包含class OrdersView(CreateModelMixin, ListModelMixin, GenericAPIView): filter_backends = (DjangoFilterBackend, OrderingFilter) filter_fields = ('product', 'team', 'buy', 'open') queryset = Order.objects.all() serializer_class = OrderListSerializer def get(self, request, *args, **kwargs): return self.list(request, *args, **kwargs) def post(self, request, *args, **kwargs): return self.create(request, *args, **kwargs)

POST

对网址的请求不会在Allow标题中包含# OPTIONS /orders/ HTTP 200 OK Allow: GET, HEAD, OPTIONS Content-Type: application/json Vary: Accept { "name": "Orders", "description": "", "renders": [ "application/json", "text/html" ], "parses": [ "application/json", "application/x-www-form-urlencoded", "multipart/form-data" ] }

POST

视图会处理Allow个请求。我希望{{1}}标题准确无误。

1 个答案:

答案 0 :(得分:0)

您需要确保拥有足够的权限才能使用POST操作。如果请求没有使用权限,DRF将不会在OPTIONS中显示它。