https://github.com/dinoperovic/django-formit
🛠️ Smiple Django form formating.
https://github.com/dinoperovic/django-formit
django format formating forms
Last synced: about 1 month ago
JSON representation
🛠️ Smiple Django form formating.
- Host: GitHub
- URL: https://github.com/dinoperovic/django-formit
- Owner: dinoperovic
- License: bsd-3-clause
- Created: 2017-05-24T13:14:54.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-10-30T13:31:24.000Z (over 8 years ago)
- Last Synced: 2025-09-30T13:14:35.197Z (8 months ago)
- Topics: django, format, formating, forms
- Language: Python
- Homepage:
- Size: 13.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Formit
[](https://travis-ci.org/dinoperovic/django-formit)
[](http://codecov.io/github/dinoperovic/django-formit)
[](https://pypi.python.org/pypi/django-formit)
**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*:
```bash
pip install django-formit
```
Then add `formit` to `INSTALLED_APPS`.
## Usage
To use **Formit** add your templates:
```django
{% 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 %}
Contact form
{% fieldset %}
{% endform_block %}
{# To render a custom form without any formating. #}
{% form_block instance blank=True %}
{% csrf_token %}
Contact form
{% fieldset fields=form.visible_fields|slice:":3" %}
{% fieldset fields=form.visible_fields|slice:"3:" %}
{% fieldset fields=form.hidden_fields %}
Send
{% 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.
[Django]: https://www.djangoproject.com/
[django-classy-tags]: https://github.com/ojii/django-classy-tags