Skip to content

Instantly share code, notes, and snippets.

@jart jart/form_errors.html
Last active Dec 11, 2015

Embed
What would you like to do?
An example of how to use Twitter Bootstrap with Django Forms
{% for error in form.non_field_errors %}
<div class="alert alert-error">{{ error }}</div>
{% endfor %}
{% for field in form %}
<div class="control-group field-{{ field.name }} {% if field.errors %}error{% endif %}">
<label class="control-label" for="id_{{ field.name }}">{{ field.label }}</label>
<div class="controls">
{{ field }}
{% if field.errors %}
<span class="help-inline">
{% for error in field.errors %}
{{ error }}
{% endfor %}
</span>
{% else %}
{% if field.help_text %}
<p class="help-block">{{ field.help_text }}</p>
{% endif %}
{% endif %}
</div>
</div>
{% endfor %}
{% extends "base.html" %}
{% block title %}Sign Up | {{ block.super }}{% endblock %}
{% block nav_signup_class %}active{% endblock %}
{% block content %}
<div class="content">
<header class="page-header">
<h1>Sign Up</h1>
</header>
<div class="row">
<div class="span9">
<h2>{{ product.descrip }} &ndash; {{ product.descrip_price }}</h2>
{% if error %}
<div class="alert alert-error">{{ error }}</div>
{% endif %}
<form class="form-horizontal" action="." method="post">{% csrf_token %}
{% include "form_errors.html" %}
<fieldset>
<legend>Account Information</legend>
{% include "form_fields.html" %}
<div class="form-actions">
<input type="submit" class="btn btn-primary" value="Sign Up">&nbsp;
</div>
</fieldset>
</form>
</div>
</div>
</div>
{% endblock content %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.