How to store variable timedeltas in a Django model?
Hello all,
In one of my models, I want to store a timedelta--a length of time not
tied to a particular start and end date. Although timedeltas are built
into Python, tragically there's no TimeDeltaField in Django.
Extra complications:
* The timedelta can be quite large -- on the scale of one week to
several months.
* The timedelta has a default value, but it can be changed by the
administrator.
* I want the default timedelta length to be one month (which, of
course, has a variable number of days!)
It seems like *someone* has to have been able to do this, if only as a
custom model field. But I wasn't able to find anything in the archives
on this list and the #django IRC logger down so I couldn't search
that. :/
I did read the docs on how to write a custom model, but it looks
terribly confusing--it's not clear which or how many of the attributes
mentioned in the docs I would need to customize, given that it *is* a
built-in Python variable type, and I have exactly zero experience
dealing with databases directly.
If anyone's got a hack around this limitation to recommend, or even
some more relevant sample code than what's in the custom model docs,
that would be super helpful!
-- Karen
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home