Created
January 24, 2015 17:01
-
-
Save vaibhav-jain/9c86d7e32605249a35e4 to your computer and use it in GitHub Desktop.
render django form errors using bootstrap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- DIV --> | |
{% if form.errors %} | |
<div class="alert alert-danger alert-dismissible" role="alert"> | |
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> | |
{% for field in form %} | |
{% if field.errors %} | |
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> | |
<span>{{ field.label }}: {{ field.errors|striptags }}</span><br> | |
{% endif %} | |
{% endfor %} | |
{% for error in form.non_field_errors %} | |
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> | |
<span>Error: {{ error|striptags }}</span> | |
{% endfor %} | |
</div> | |
{% endif %} | |
<!-- /DIV --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment