Skip to main content

django-bootstrap-form-horizontal

This is set of form templates that implement a bootstrap “horizontal” style for Django forms. Handles all default field types, including a nice Pikaday wrapper for date time fields.

Installation:

pip install django-bootstrap-form-horizontal

Add to INSTALLED_APPS:

INSTALLED_APPS = (
     ...
     "bootstrap_form_horizontal",
     ...
)

Usage:

{% include "bootstrap_form_horizontal.html" with form=myform %}

The template accepts the following context:

  • form: The form to render.

  • submit: The text for a submit button with class btn btn-primary. If not specified, no submit button is rendered.

  • wrap: If not 0, will wrap form with <form method='post' action='' class='form-horizontal'>{% csrf_token %} ... </form>. Default: True If you specify wrap=0, the form will be rendered without wrapping, and you must provide your own class='form-horizontal' wrapper.

  • label_class: The grid class(es) to use on label elements. Default: col-sm-4.

  • field_class: The grid class(es) to use on field elements. Default: col-sm-8.

To render properly, you must include various css/js. For convenience, vendored bootstrap is included here – though you probably are already loading it in your project if you’re interested in this app:

<!-- Bootstrap -->
<link rel='stylesheet' type='text/css' href='{{ STATIC_URL }}bootstrap_form_horizontal/vendor/bootstrap/css/bootstrap.css' />
<script type='text/javascript' src='{{ STATIC_URL }}bootstrap_form_horizontal/vendor/bootstrap/js/bootstrap.min.js'></script>

<!-- Pikaday -->
<link rel='stylesheet' type='text/css' href='{{ STATIC_URL }}bootstrap_form_horizontal/vendor/pikaday/css/pikaday.css' />
<script type='text/javascript' src='{{ STATIC_URL }}bootstrap_form_horizontal/vendor/pikaday/pikaday.js'></script>
<script type='text/javascript' src='{{ STATIC_URL }}bootstrap_form_horizontal/datewidgets.js'></script>

Examples

Wrap with form, and include submit button:

{% include "bootstrap_form_horizontal.html" with form=myform submit="Send it in" %}

Do your own form wrapping:

<form method='post' class='form-horizontal' action='something'>{% csrf_token %}
    {% include "bootstrap_form_horizontal.html" with form=myform wrap=0 %}
    <input type='submit' value='Go!' />
</form>

Change the responsive column classes:

{% include "bootstrap_form_horizontal.html" with label_class='col-sm-2 col-xs-4' field_class='col-xs-10 col-sm-8' %}
Rolling your own form template?
  • _bootstrap_form_horizontal_field.html: renders a single label/field pair. Expects field as context; also accepts label_class and field_class as above.

  • _bootstrap_form_horizontal_non_field_errors.html: Displays non-field errors wrapped in bootstrap error classes. Expects form as context; accepts label_class and field_class.

Source

File issues, download, etc. at https://github.com/yourcelf/django-bootstrap-form-horizontal.git.

Metadata

Release files for django-bootstrap-form-horizontal 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-bootstrap-form-horizontal 0.0.4
File Size Uploaded Provenance Actions
django-bootstrap-form-horizontal-0.0.4.tar.gz 251.2 kB Without provenance Details for django-bootstrap-form-horizontal-0.0.4.tar.gz

Release files / django-bootstrap-form-horizontal-0.0.4.tar.gz

Download URL django-bootstrap-form-horizontal-0.0.4.tar.gz
Size 251.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8430d61cc4532d6998327d902e495bd2bf414d1433bb1de500c19dc568fdb98c
BLAKE2b-256 checksum
How to use checksums
3e46ae45f1b820be3d8c40ad6e6ff8598cf05af49f2196183428d7508c257f02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-bootstrap-form-horizontal 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page