Django:访问表单集中的每个表单和FileField
如何迭代表单集以获取每个表单以及该表单中的文件字段?
for file in formset.files:
....
for form in formset.forms:
....
我希望上面的内容在同一个循环中,因为我同时需要它们!
How can I iterate thorugh a formset to get each form and FileField for in that form?
for file in formset.files:
....
for form in formset.forms:
....
I'd like the above in the same loop since I need both of them in the same time!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题有点令人困惑,但是如果您正在同一循环中查找表单对象和上传的文件,那么它看起来像这样:
如果不是,请澄清。
Your question is a little confusing, but if you're looking for your form object and uploaded file in the same loop, it would look like so:
If not, please clarify.