A reusable Django application for rendering forms with Foundation for Sites.
Project description
A reusable Django application for rendering forms with Foundation for Sites.
Requirements
Python 3.5, 3.6 and 3.7
Django 2.0.x, 2.1.x and 2.2.x (Jinja2 is not supported yet)
Foundation for Sites 6.x
Note that this application does not include Foundation for Sites assets so that you can customize it as you need. Get started by reading its documentation!
Features
Displays the field label as well as its help text
Renders the Django base Widgets following the Forms component’s guidelines
Shows the field errors as needed and sets the proper CSS classes on the field label and the input
Installation
Install Foundation Forms for Django:
pip install django-fsforms
Add it to the INSTALLED_APPS in your settings.py:
INSTALLED_APPS = ( ... 'fsforms', ... )
Set the FORM_RENDERER in your settings.py to use fsforms’ one:
If you are using Django templates:
FORM_RENDERER = 'fsforms.renderers.DjangoTemplates'
If you are using TemplateSetting as form renderer, you just have to ensure that the fsforms templates will be sourced before the built-in widgets templates directory.
Note that this step is required since Django is loading templates first from the built-in form templates directory in django/forms when using those backends (see the Built-in-template form renderers’ doc).
Usage
In your template, you will just have to load fsforms then use the fsfield tag to render a form field.
{% load fsforms %}
<form action="/url/to/submit/" method="post">
{% csrf_token %}
<ul class="no-bullet">
<li>{% fsfield form.simple_field %}</li>
<li>{% fsfield form.other_field label_class="my-field" %}</li>
</ul>
<div class="button-holder">
<button type="submit" class="button">Submit</button>
</div>
</form>
Here are the special arguments you can pass to the fsfield tag: - show_label: a boolean which turns on or off the label output. Note that label of choices widgets will always be displayed. - label_class: a string which contains additional CSS classes to apply to the label element. - show_errors: a boolean which turns on or off the field errors’ output as well as the CSS classes applied to the elements - e.g. is-invalid-input and is-invalid-label. Default is True. - as_list: a boolean which controls the rendering of choices widgets - i.e. RadioSelect and CheckboxSelectMultiple. When set to True - the default, the fields will be rendered inline and wrapped inside a fieldset as suggested by the Forms component. Otherwise, they will be rendered as a list.
All the remaining arguments will be added to the widget attributes. As regards the required one, you can alter its value too but only with client-side effect. It means that if a field is defined as required in the form class and you pass required=False to the tag, it will appear as non-required to the user but will still be validated at the form’s submission.
License
You can use this under GNU AGPLv3+. See LICENSE file for details.
Changelog
[6.0.0] - 2019-09-23
Fixed
Add compatibility for Django >= 2.1 and Python 3.5
[6.0.0rc2] - 2018-04-11
Added
fsfield tag to render a form field using Foundation Forms structure.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-fsforms-6.0.0.tar.gz
.
File metadata
- Download URL: django-fsforms-6.0.0.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 799870aa3122de7cd57ee513f5bd9fe31733d97a4242b4c0bf69f98817bbd6a8 |
|
MD5 | ccf691cf4bb914ce9e45e8c573be7095 |
|
BLAKE2b-256 | b835d034357ede71797e67dd8ad72ad9e2ff9682391fc543039c94d0655cf1c5 |
File details
Details for the file django_fsforms-6.0.0-py3-none-any.whl
.
File metadata
- Download URL: django_fsforms-6.0.0-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5378b47ac3fef460464b7c9e9deead58f7ad832b7f2cf59f448c02add3e6e09 |
|
MD5 | 3b83076715c11f191bd1b96fe140825d |
|
BLAKE2b-256 | 79981c6c1a41154b515dd0ce90ea84349cd679050af5b869bce6a9798f11bc5c |