django-stdfields

Fields I wish were standard in Django. At the moment this is limited to the
MinutesField, EnumIntegerField and EnumCharField.

Install:

pip install django-stdfields

Contents

stdfields.forms.MinutesField: use an integer to represent a duration of
minutes and hours

stdfields.fields.EnumIntegerField: makes working with choices a bit
easier

stdfields.fields.EnumCharField: the same, but for choices with a char
key

MinutesField

Is an extension of Django's standard django.forms.IntegerField.

This field will accept values for a duration in minutes in the formats
hh:mm or h.fraction, similar to the way BaseCamp allows you to specify
your time spent on a task as either 8:30 or 8.5. In the latter case only
8.25, 8.5, 8.50 and 8.75 are considered valid inputs.

This example is basically the same as the above since EnumCharField is a
subclass of the regular Django CharField. By using the enum keyword
argument of the enum field, the choices will be automatically updated when you
update the enumeration object. And since you're using the provided
max_length method of Enumeration, the max_length will be updated
when needed. Just like in the previous example. The enum fields simply offer
some more clarity when reading the code.

EnumIntegerField works exactly the same, but for enumerations with integer
keys. Both fields can be used with South.