I would like to use an inline model form with a 'django-autocomplete-light field'. I'm a little bit desperate also, because I don't know 'javascript' well. This is a picture of my form. At first glance, it works as desired:
Unfortunately, only the first field loads correctly. If I add more fields there are errors (see pictures).
This is my form template where I suspect the error, because the first field works correctly as desired.
<div class="container">
<form method="post" action="">
{% csrf_token %}
{{ form.as_p }}
<!-- Medication Table -->
<table class="table">
{{ medication.management_form }}
{% for form in medication.forms %}
{% if forloop.first %}
<thead>
<tr>
{% for field in form.visible_fields %}
<th>{{ field.label|capfirst }}</th>
{% endfor %}
</tr>
</thead>
{% endif %}
<tr class="{% cycle "row1" "row2" %} formset_row">
{% for field in form.visible_fields %}
<td>
{# Include the hidden fields in the form #}
{% if forloop.first %}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
{% endif %}
{{ field.errors.as_ul }}
{{ field }}
</td>
{% endfor %}
</tr>
{% endfor %}
</table>
<input type="submit" value="Submit Form"/>
<script type="text/javascript" src="{% static '/js/core/jquery.3.2.1.min.js' %}"></script>
{{ form.media }}
<!-- script for add, delete, update -->
<script src="{% static 'formset/jquery.formset.js' %}"></script>
<script type="text/javascript">
$('.formset_row').formset({
addText: 'add medication',
deleteText: 'remove',
prefix: 'medication_set'
});
</script>
</div>