[Django]-Why aren't labels appearing in my Django ModelForm?

0👍

The only solution I managed to find that still allowed me to separate each row of the form was doing the following:

<form method="POST" action="{% url some_url %}">
    {% csrf_token %}
    {{ formset.as_ul }}
    <div class="actions">
        <input class="button submit focus" type="submit" value="{% trans "Save" %}" />
    </div>
</form>

… the key piece being the {{ formset.as_ul }} instead of iterating through each field.

As for why the other listed solution (or the solution in the documentation) didn’t work, I will remain baffled.

👤NT3RP

0👍

You have to put the field label inside a <label> tag. So:

<div>
    <label for="id_{{field.html_name}}">{{field.label}}:</label>
    {{ field }}
</div>
👤Basti

Leave a comment