i have one form and use it many times with a for loop in one template file. I want to set the values of the fields in my templates directly. I use Django-bootstrap4 and didn't now how to realize it.
I tried the template tags "bootstrap_form" and "bootstrap_field", but I can't set the value of the fields.
1) for loop with the form without initializing the values (worked):
{% for item in items %}
<div class="modal fade" id="item_modal_{{item.id}}" ...>
<div class="modal-content">
<div class="modal-body">
{% bootstrap_form form %}
</div>
</div>
</div>
{% endfor %}
2) Now I want to initial the form fields with the item values. I tried this:
{% for item in items %}
<div class="modal fade" id="item_modal_{{item.id}}" ...>
<div class="modal-content">
<div class="modal-body">
{% bootstrap_field form.field1 value=item.field1 %}
{% bootstrap_field form.field2 value=item.field2 %}
{% bootstrap_field form.field3 value=item.field3 %}
{% bootstrap_field form.field4 value=item.field4 %}
</div>
</div>
</div>
{% endfor %}
Thank you!