Sunday, August 14, 2011

Re: How to store variable timedeltas in a Django model?

Depending on the resolution and maximum duration, you could just use
an integerfield containing either the number of seconds or minutes,
and then recreate it. That way you can also base queries off of the
value, which you can't do with just a pickle field. Of you could
subclass the integerfield and make it accept/return timdelta objects
similar to how the pickled version is above.

The max duration depends on the data type in your database backend.
Postgres I think is +/- -214748364 or so. If you use a resolution of
seconds, that is a limit of about 68 years. Using minute resolution
would be about 4 millenia.

--
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


Real Estate