Skip to main content

A collection of useful templates for customizing crispy forms layouts.

Project description

=============================
crispy-templates
=============================

.. image:: https://badge.fury.io/py/crispy-templates.png
:target: https://badge.fury.io/py/crispy-templates

A collection of useful templates for customizing crispy forms layouts.

Documentation
-------------

The full documentation is at https://crispy-templates.readthedocs.io.

Quickstart
----------

crispy-templates depends on [crispy-forms](https://github.com/django-crispy-forms/django-crispy-forms#django-crispy-forms), make sure that you have properly installed crispy forms first.

Install crispy-templates::

pip install crispy-templates

Add it to your `INSTALLED_APPS`:

.. code-block:: python

INSTALLED_APPS = (
...
'crispy_templates.apps.CrispyTemplatesConfig',
...
)

Define your layout template in the `crispy_forms.helper.FormHelper` object:

.. code-block:: python
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Field, Layout

class BookForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super(BookForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.template_pack = "bootstrap3"
self.helper.layout = Layout(
Field('publication_status', template="crispy_templates/layouts/radio_btngroup_field.html"),
)

Add the javascript by running `python manage.py collectstatic` and then including it in your template:

.. code-block:: python

{% static 'crispy_templates/js/crispy_templates.js' %}

Preferably add it to the footer of your page so as to not delay the page load.
**Note** - Currently only supports the `bootstrap3` template pack that comes with `crispy_forms`.

Credits
-------

Tools used in rendering this package:

* Cookiecutter_
* `cookiecutter-djangopackage`_

.. _Cookiecutter: https://github.com/audreyr/cookiecutter
.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage




History
-------

0.2.0 (2017-01-17)
++++++++++++++++++

* Fixed method of rendering field so form would pull out the data
* Refactored how the project templates were structured and how to include the new template override
* Updated documentation

0.1.0 (2017-01-14)
++++++++++++++++++

* First release on PyPI.

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

crispy-templates-0.2.0.tar.gz (6.0 kB view details)

Uploaded Source

File details

Details for the file crispy-templates-0.2.0.tar.gz.

File metadata

File hashes

Hashes for crispy-templates-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0a95cd84e8e91d8c8f7ba7600578caf6e3f28df3d800860524b0fd191085822c
MD5 c9c6c0d1d958431f2550a9237bf1473d
BLAKE2b-256 f94afe746465e06b31c451f5628be23167c9904fa1b706688c60097d7b4b04f1

See more details on using hashes here.

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