Skip to content

Instantly share code, notes, and snippets.

@ydnax
Created January 31, 2012 15:37
Show Gist options
  • Save ydnax/1711116 to your computer and use it in GitHub Desktop.
Save ydnax/1711116 to your computer and use it in GitHub Desktop.
basic template for django forms with twitter bootstrap style error messages
{% extends "base.html" %}
{% block title %}
{{ title }}
{% endblock %}
{% block content %}
<form action="{{ action }}" method="{% block method %}post{% endblock %}">
{% for field in form %}
<div>
{% if field.errors %}
<div class="alert-message block-message error">
{{ field.label_tag }}: {{ field }} {{ field.errors }}
</div>
{% else %}
{{ field.label_tag }}: {{ field }}
{% endif %}
</div>
{% endfor %}
{% csrf_token %}
<input type="submit" value="{% block submittext %}Submit{% endblock %}" />
</form>
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment