我有一个 Django Rest-framework APIView 类,如下所示:
class HelloView(APIView):
def get(self, request):
clients = client.objects.all()
serializer = ClientSerializerAPIView(clients, many=True)
return Response(serializer.data)
def post(self, request):
serializer = ClientSerializerAPIView(data=request.data)
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_404_NOT_FOUND)
当我通过邮递员发送 get 请求时,邮递员的 cookie 部分中有一个 csrf 令牌,但问题是在收到的头文件中没有 Set-Cookie 字段供我从中获取 gram csrftoken。