【发布时间】:2015-05-02 20:49:44
【问题描述】:
我正在对我的其余框架 API、我的模型进行单元测试:
class attach():
attachment = models.ImageField
name = models.CharField
然后我尝试通过我定义的 API 发布(此处未显示标准序列化程序)
c = Client()
with open('wishlist.doc') as fp:
c.post('/customers/wishes/', {'name': 'fred', 'attachment': fp}, format='multipart')
我得到以下堆栈跟踪
ValueError: The 'attachment' attribute has no file associated with it.
如何将密钥附件与文件关联
【问题讨论】:
标签: django-rest-framework python-unittest