[Fixed]-How to print ValidationError?

1👍

The as_data() method is useful if you want to access the ValidationError instances. If all you want to do is access the error messages, then use form.errors instead of form.errors.as_data()

{% if form.errors %}
    {% for field, error in form.errors.items %}
        <div class="alert alert-danger">
            {{ field }} - {{ error }}
        </div>
    {% endfor %}
{% endif %}

Leave a comment