Code Documentation¶
Models¶
Fields¶
-
class
localized_recurrence.fields.
DurationField
(*args, **kwargs)¶ A field to store durations of time with accuracy to the second.
A Duration Field will automatically convert between python timedelta objects and database integers.
Duration fields can be used to define fields in a django model
class Presentations(models.Model): length = DurationField() speaker = models.ForeignKey(User) location = models.ForeignKey(Location)
Given such a model, storing a duration in the database is as simple as passing in a
timedelta
object>>> Presentations.objects.create( ... length=datetime.timedelta(minutes=45), ... speaker=User.objects.get(email='MrT@example.com'), ... location=wrestle_mania_ring, ... )
The timedeltas are stored as seconds in the backend, so sub-second accuracy is lost with this field.