Skip to main content
 首页 » 编程设计

python之是否可以通过 django 测试客户端中的 post 请求传递 request.body

2024年10月24日33kerrycode

到目前为止我还没有找到任何方法。

https://docs.djangoproject.com/en/1.8/topics/testing/tools/#django.test.Client.options  

显示选项允许通过 get 请求请求.body 但找不到任何方式通过 post 请求传递。任何想法,我已经找了几个小时了。

请您参考如下方法:

是的:

self.client.generic('POST', '/url', 'raw post data')