Last active
December 11, 2015 01:39
-
-
Save jart/4525270 to your computer and use it in GitHub Desktop.
An example of how to use Twitter Bootstrap with Django Forms
This file contains 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
{% for error in form.non_field_errors %} | |
<div class="alert alert-error">{{ error }}</div> | |
{% endfor %} |
This file contains 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
{% 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 %} |
This file contains 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
{% 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 }} – {{ 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"> | |
</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