Skip to content

Instantly share code, notes, and snippets.

@BradWhittington
Last active December 18, 2015 22:49
Show Gist options
  • Save BradWhittington/5857433 to your computer and use it in GitHub Desktop.
Save BradWhittington/5857433 to your computer and use it in GitHub Desktop.
Form skillz for django
{% csrf_token %}
{% if form.non_field_errors %}<div class="non_field_errors">{{form.non_field_errors}}</div>{%endif %}
{% for field in form.visible_fields %}
{% load klass %}
<div class="field_wrapper field_{{field.name}} input_{{field.field.widget|klass}} {% if field.errors %}has_errors{% endif %}">
{% if field.field.widget|klass == 'CheckboxInput' %}
{{ field }}
{{ field.label_tag }}
{% else %}
{{ field.label_tag }}
{{ field }}
{% endif %}
{{ field.errors }}
{% if field.help_text %}
<p class="help_text">{{field.help_text}}</p>
{% endif %}
</div>
{% endfor %}
{% for hidden in form.hidden_fields %}
{{ hidden }}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment