Skip to main content

Simple Django form formating

Project description

# Formit

[![Build Status](](
[![PyPI version](](

**Smiple [Django] form formating.**

Formit provides a template tag library for django to ease the formating of forms.


## Requirements

* [Django] 1.11, 1.10
* [django-classy-tags] for managing template tags.

## Installation

Install using *pip*:

pip install django-formit

Then add `formit` to `INSTALLED_APPS`.

## Usage

To use **Formit** add your templates:

{% load formit_tags %}

{# To render the form pass in the string path or form instance. #}
{% form 'contact.forms.ContactForm' action="/" method="get" button="Send" %}

{# To render the form with custom contents. #}
{% form_block instance %}
<h3>Contact form</h3>
{% fieldset %}
{% endform_block %}

{# To render a custom form without any formating. #}
{% form_block instance blank=True %}
{% csrf_token %}
<h3>Contact form</h3>
<div class="column">
{% fieldset fields=form.visible_fields|slice:":3" %}
<div class="column">
{% fieldset fields=form.visible_fields|slice:"3:" %}
{% fieldset fields=form.hidden_fields %}
{% endform_block %}

{# You can separate the rendering of visible and hidden fields. #}
{% fieldset visible_fields=instance.visible_fields hidden_fields=instance.hidden_fields %}
{# or to automatically extract them from a form. #}
{% fieldset form=instance %}

{# To render a single field #}
{% field instance.visible_fields.0 placeholder="Enter your name" %}

Fieldset tags can also be used without any arguments. In that case ``form`` from the context will be used,
which is automatically available inside the ``form`` or ``form_block`` tag.

## Templates

Templates available to override in ``templates/formit/*``:

* ``form.html``
* ``fieldset.html``
* ``field.html``

You can specify custom templates for each field widget by adding a template with lowercase class name of the widget.
For example ``formit/fields/textinput.html`` will render a `TextInput` widget.


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-formit-0.1.3.tar.gz (6.3 kB view hashes)

Uploaded source

Built Distribution

django_formit-0.1.3-py2.py3-none-any.whl (9.7 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page