【发布时间】:2009-12-20 20:09:27
【问题描述】:
Django 文档 (http://docs.djangoproject.com/en/dev/topics/testing/#django.test.client.Client.post) 说要这样做:
>>> c = Client()
>>> f = open('wishlist.doc')
>>> c.post('/customers/wishes/', {'name': 'fred', 'attachment': f})
>>> f.close()
但是当我这样做时,该字段会显示错误消息“提交的文件为空”。这听起来像是一个 PIL 问题,但该表单在实际站点上运行良好。
读取文件并发送它而不仅仅是句柄也不起作用,其行为与传递空字符串相同。
【问题讨论】: