Welcome to thecut-forms¶
Form rendering helpers.
Features¶
- Automatically add appropriate HTML5
type,requiredandmaxlengthattributes to form fields. - Automatically add
date,time, anddatetimeCSS classes to appropriate form fields. - Easily add custom
placeholdersto form fields by editing adict. - Easily render forms in your templates in a well-designed standardised way that makes front-end development easier.
Documentation¶
The full documentation is at https://thecut-forms.readthedocs.org.
Quickstart¶
Install thecut-forms using the Installation instructions.
Use one of the many available django.forms.Form mixins on your django.forms.Form:
from django import forms
from thecut.forms import EmailTypeMixin, TimeClassMixin
class MyForm(EmailTypeMixin, TimeClassMixin, forms.Form):
foo = forms.EmailField(required=True)
bar = forms.TimeField(required=True)
Or use thecut.forms.forms.FormMixin to get them all at once:
from django import forms
from thecut.forms import FormMixin
class MyForm(FormMixin, forms.Form):
foo = forms.CharField(required=True)
See Form Mixins for more information.
In your template, use the forms/_form.html snippet to easily render your forms:
{% include "forms/_form.html" %}
See Templates for more information.