Django application to add 'django-crispy-forms' layout objects for the GOV.UK Design System.
Project description
A GOV.UK Design System template pack for django-crispy-forms, for simple and powerful form generation which is compliant with GDS usability and accessibility guidelines.
Requires Django 2.2 or later and django-crispy-forms 1.9 or later.
Quickstart
This is a minimal howto without options or details - see the crispy-forms-gds documentation for full instructions for installation and usage.
Install using pip:
pip install crispy-forms-gds
Add to installed apps, with settings to tell django-crispy-forms to use this theme:
INSTALLED_APPS = [ ... 'crispy_forms', 'crispy_forms_gds', ] CRISPY_ALLOWED_TEMPLATE_PACKS = ["gds"] CRISPY_TEMPLATE_PACK = "gds"
Build a regular crispy form using layout objects from crispy_forms_gds:
from django import forms from crispy_forms_gds.helper import FormHelper from crispy_forms_gds.layout import Submit class TextInputForm(forms.Form): name = forms.CharField( label="Name", help_text="Your full name.", widget=forms.TextInput(), error_messages={ "required": "Enter your name as it appears on your passport" } ) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = FormHelper() self.helper.add_input(Submit("submit", "Submit"))
Render the form in your templates as normal:
{% load crispy_forms_tags %} {% crispy form %}
Open the page in your browser:
Features
The template pack supports all the basic components listed in the GOV.UK Design System:
Demo
If you checkout the code from the repository, there is a Django site you can run to see the forms in action. You will need to install nvm first (to manage node versions), then build and run the demo with:
make serve
Further reading
Read the documentation on Read the docs
Download the PyPi package
Learn more about Django Crispy Forms
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 Distributions
Hashes for crispy_forms_gds-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d75fec5f94de70068cc1a19ba86247f80437f8afe785bc927fc787556ea72568 |
|
MD5 | 2cfa78fe1358cfaa6d331bb140656b4b |
|
BLAKE2b-256 | 56aa32078739307ed3e2838ed95768f7a58e93d774ec1d42d3ac7b0d7ad82599 |
Hashes for crispy_forms_gds-0.2.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50915504166be3710e19878d096309053a108a31aa586954b95725b6f560703c |
|
MD5 | a97b677a2e663f09cea018558ac7609c |
|
BLAKE2b-256 | 6a832166debca3c262ca2afe39478e62ff201bb65bdb5ec9737a98cbd61ff8f9 |