Django 文件字段问题
文件字段在管理中工作得很好,但在模板中提交时不会上传任何内容。表单返回文件字段时出现“必需”错误。
路径似乎是正确的,如果不是,我认为文件字段将无法在管理员中工作。
花了几个小时在这上面,我很困惑。我用的是后备箱。有想法吗?
filefield works just fine in the admin, but in a template nothing is uploaded upon submit. the form comes back with a "required" error for the filefield.
the paths seem to be right, and if they weren't, I don't think filefield would be working in the admin.
spent hours on this and I'm stumped. I'm using trunk. Ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
http://docs.djangoproject.com/en /dev/ref/forms/api/#binding-uploaded-files
明白了。我没有将 request.FILES 发送到 modelform 构造函数。
文件字段的 django 模型参考没有提到将上传的文件绑定到表单的特殊考虑,但话又说回来,我完全是个菜鸟。希望这对其他人有帮助!
http://docs.djangoproject.com/en/dev/ref/forms/api/#binding-uploaded-files
Got it. I wasn't sending in request.FILES to the modelform constructor.
The django model reference for filefield doesn't mention special consideration for binding uploaded files to a form, but then again, I'm a total noob. Hopefully this helps someone else!