Skip to content

Instantly share code, notes, and snippets.

@mtrythall
Last active October 8, 2015 23:48
Show Gist options
  • Save mtrythall/3406637 to your computer and use it in GitHub Desktop.
Save mtrythall/3406637 to your computer and use it in GitHub Desktop.
Basic field include for Django templates
<div class="field {% if field_class %} {{ field_class }}{% endif %}">
<label for="id_{{ field.html_name }}">
{% if label %}{{ label }}{% else %}{{ field.label }}{% endif %}
{% if not field.required %}<small>optional</small>{% endif %}
</label>
{{ field }}
{% if help_text %}
<p class="help-text">{{ help_text }}</p>
{% elif field.help_text %}
<p class="help-text">{{ field.help_text }}</p>
{% endif %}
{{ field.errors }}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment