2👍
✅
HTML does not permit block elements like ul
inside p
elements. So when your field has an error, which is rendered with a ul
, your browser helpfully closes the p
to make it valid. (What you’re looking at is the browser’s DOM representation, not the actual rendered HTML which won’t contain the magic close elements: do “view source” to see this.)
You should move the error tag out of the p
. If you like, you can wrap the whole thing in something like a div
.
0👍
It looks like you didn’t initialize your form in the html.
See the following example:
<form method="post" action="." enctype="multipart/form-data">
{% csrf_token %}
{% for field in my_form %}
<p>{{ field.label_tag }} {{ field }}</p>
{% endfor %}
<input type="submit" value="Submit Form" />
</form>
- [Answered ]-Want difference from standard value for each value of row using Django ORM
- [Answered ]-Not able to use foreign key from another app?
- [Answered ]-How to compare Specific value of two different tables in django?
- [Answered ]-TypeError: context must be a dict rather than Context
Source:stackexchange.com