来自Django文档
Client.post:
提交文件是一种特殊情况。要发布文件,只需提供文件字段名称作为键,并提供要上传的文件的文件句柄作为值。例如:
c = Client()with open('wishlist.doc') as fp: c.post('/customers/wishes/', {'name': 'fred', 'attachment': fp})
来自Django文档
Client.post:
提交文件是一种特殊情况。要发布文件,只需提供文件字段名称作为键,并提供要上传的文件的文件句柄作为值。例如:
c = Client()with open('wishlist.doc') as fp: c.post('/customers/wishes/', {'name': 'fred', 'attachment': fp})