Skip to main content

Best way to have Django DRY forms

Project description

https://github.com/django-crispy-forms/django-crispy-forms/actions/workflows/main.yml/badge.svg https://img.shields.io/badge/code%20style-black-000000.svg http://codecov.io/github/django-crispy-forms/django-crispy-forms/coverage.svg?branch=main

The best way to have Django DRY forms. Build programmatic reusable layouts out of components, having full control of the rendered HTML without writing HTML in templates. All this without breaking the standard way of doing things in Django, so it plays nice with any other form application.

django-crispy-forms supports Django 4.2+ with Python 3.8+.

Looking for Bootstrap 5 support? See the crispy-bootstrap5 package.

The application mainly provides:

  • A filter named |crispy that will render elegant div based forms. Think of it as the built-in methods: as_table, as_ul and as_p. You cannot tune up the output, but it is easy to start using it.

  • A tag named {% crispy %} that will render a form based on your configuration and specific layout setup. This gives you amazing power without much hassle, helping you save tons of time.

Django-crispy-forms supports several frontend frameworks, such as Twitter Bootstrap (versions 2, 3, and 4), tailwind, Bulma and Foundation. You can also easily adapt your custom company’s one, creating your own, see the docs for more information. You can easily switch among them using CRISPY_TEMPLATE_PACK setting variable.

Authors

django-crispy-forms is the new django-uni-form. django-uni-form was an application created by Daniel Greenfeld that I led since version 0.8.0. The name change tries to better explain the purpose of the application, which changed in a significant way since its birth.

If you are upgrading from django-uni-form, we have instructions for helping you.

Example

This is a teaser of what you can do with latest django-crispy-forms. Find here the gist for generating this form:

http://i.imgur.com/LSREg.png

Documentation

For extensive documentation see the docs folder or read it on readthedocs

Special thanks

  • To Daniel Feldroy (@pydanny) for his support, time and the opportunity given to me to do this.

  • The name of the project was suggested by the fantastic Audrey Feldroy (@audreyfeldroy)

  • To Kenneth Love (@kennethlove) for creating django-uni-form-contrib from which bootstrap template pack was started.

Download files

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

Source Distribution

django-crispy-forms-2.1.tar.gz (278.6 kB view hashes)

Uploaded source

Built Distribution

django_crispy_forms-2.1-py3-none-any.whl (31.4 kB view hashes)

Uploaded py3

Supported by

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