Insert for loop item in django output field

假如想象 提交于 2019-12-11 17:51:02

问题


I have a for loop in my django template:

{% for item in data %}

{{ item.Load}}
{{ item.To }}
{{ item.From }}
{{ item.Weight }}

and I want to parse item.load in this format

{{ forminput.field.value|default_if_none:"" }}

but when I do this,

{{ forminput.field.item.Load|default_if_none:"" }}

it doesn't show my field in the django form. When I enter a static value(e.g. 3) in this it appears in the form like this

{{ forminput.Load_ID.3|default_if_none:"" }}

it shows the 4th object on the page.

How can I insert item.Load in value ?

Here's the link from which I took the code: Display value of a django form field in a template?

来源:https://stackoverflow.com/questions/55412392/insert-for-loop-item-in-django-output-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!