Form Mixins

The following mixins can be applied to any Form-type object.

EmailTypeMixin

class thecut.forms.forms.EmailTypeMixin(*args, **kwargs)

A mixin for a Form that sets the HTML5 email input type on any child EmailField instances.

RequiredMixin

class thecut.forms.forms.RequiredMixin(*args, **kwargs)

A mixin for a Form that sets the HTML5 required attribute on any child Field instances that is required.

This mixin does not apply the required attribute to fields using RadioSelect and CheckboxSelectMultiple as the HTML5 required attribute does not behave as (usually) expected on these widgets.

MaxLengthMixin

class thecut.forms.forms.MaxLengthMixin(*args, **kwargs)

A mixin for a Form that sets the HTML5 maxlength attribute on any child Field instances using the Textarea widget.

A max_length must be specified on the Field.

PlaceholderMixin

class thecut.forms.forms.PlaceholderMixin(*args, **kwargs)

A mixin for a Form that allows you to easily set the HTML5 placeholder widget on a child Field.

To add a placeholder to a Field, specify it in a placeholders dict on the Form‘s Meta class. For example:

class MyForm(forms.Form):

    foo = forms.CharField()

    class Meta(object):
        placeholders = {
            'foo': 'Enter some text here.'
        }

TimeClassMixin

class thecut.forms.forms.TimeClassMixin(*args, **kwargs)

A mixin for a Form that adds a time CSS class on any child Field instances using the TimeInput widget..

DateClassMixin

class thecut.forms.forms.DateClassMixin(*args, **kwargs)

A mixin for a Form that adds a date CSS class on any child Field instances using the DateInput widget..

DateTimeClassMixin

class thecut.forms.forms.DateTimeClassMixin(*args, **kwargs)

A mixin for a Form that adds a datetime CSS class on any child Field instances using the DateTimeInput widget..

FormMixin

In order to make it easy to use all of the above mixins, we have provided thecut.forms.forms.FormMixin which inherits from all other mixins.

class thecut.forms.forms.FormMixin(*args, **kwargs)

Bases: thecut.forms.forms.DateTimeClassMixin, thecut.forms.forms.DateClassMixin, thecut.forms.forms.EmailTypeMixin, thecut.forms.forms.MaxLengthMixin, thecut.forms.forms.PlaceholderMixin, thecut.forms.forms.RequiredMixin, thecut.forms.forms.TimeClassMixin

Form mixin.

Used to extend a standard Django Form class with useful/common behaviour.