django form template with bootstrap
- Author:
- youyongsong
- Posted:
- January 25, 2015
- Language:
- Python
- Version:
- Not specified
- Score:
- 2 (after 2 ratings)
required
{% load trans%}
before using this snippets
- Add this template filter to your custom templatetags and load it before using this snippets
- Bootstrap framework
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 | <form role="form" action="." method="post"> {% csrf_token %}
{% if form.non_field_errors %}
<div class="alert alert-danger">{{ form.non_field_errors|join:"<br \>" }}</div>
{% endif %}
{% for field in form %}
<div class="form-group {% if field.errors %}has-error{% endif %}">
{{ field.label_tag|add_class:"control-label" }}
{% if field.help_text %}
<span class="help-block">{{ field.help_text }}</span>
{% endif %}
{% if field.errors %}
<span class="help-block">{{ field.errors|join:"<br \>" }}</span>
{% endif %}
{{ field|add_class:"form-control" }}
</div>
{% endfor %}
<input class="btn btn-success" type="submit" value="{% trans 'submit' %}">
</form>
|
Comments
Please login first before commenting.