问题
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