0👍
✅
the problem would be solved with this code lines:
{% for field in form %}
<div class="row">
<div class="error">{{ field.errors }}</div>
<br/>
<div class="lable">{{ field.label }}</div>
<div class="field">{{ field }}</div>
</div>
{% endfor %}
😉
2👍
You get errors in field_name.errors
for each field.
form.errors
gives any error for entire form and not specific to a field.
Refer below sample from django docs here
<form action="/contact/" method="post">
{% for field in form %}
<div class="fieldWrapper">
{{ field.errors }}
{{ field.label_tag }}: {{ field }}
</div>
{% endfor %}
<p><input type="submit" value="Send message" /></p>
- [Answered ]-Giving positions name in django automatically
- [Answered ]-Django / DRF – Changing the timezone does not work
- [Answered ]-How to display/use a dropdown in the django admin
- [Answered ]-How to register a new Model in Django-Oscar Dashboard?
- [Answered ]-Django : Writing a query with condition referencing aggregation within same table
Source:stackexchange.com