Last active
August 29, 2015 13:56
-
-
Save timster/8964950 to your computer and use it in GitHub Desktop.
Generic Django form renderer
This file contains hidden or 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
{% if form.non_field_errors %} | |
<ul class="errors non-field-errors"> | |
{% for err in form.non_field_errors %} | |
<li>{{ err }}</li> | |
{% endfor %} | |
</ul> | |
{% endif %} | |
<div style="display:none">{% csrf_token %}</div> | |
{% for hidden in form.hidden_fields %} | |
<div style="display:none">{{ hidden }}</div> | |
{% endfor %} | |
{% for field in form.visible_fields %} | |
<div class="field {% if field.errors %}field-with-errors{% endif %}"> | |
{% if field.errors %} | |
<ul class="errors"> | |
{% for err in field.errors %} | |
<li>{{ err }}</li> | |
{% endfor %} | |
</ul> | |
{% endif %} | |
{% if field.is_checkbox %} | |
<div class="checkbox">{{ field }}{{ field.label_tag }}</div> | |
{% else %} | |
<div class="input"> | |
{{ field.label_tag }}{{ field }} | |
{% if field.field.help_text and not request.is_ajax %} | |
<span class="helptext">{{ field.field.help_text|safe }}</span> | |
{% endif %} | |
</div> | |
{% endif %} | |
</div> | |
{% endfor %} | |
{{ form.media }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment