Friday, April 17, 2015

DurationField with default value

Hi,    I'm trying to figure out how to use a default value with a duration field.    When I use time_passed = models.DurationField(default=0):      * Migrations work    * Form defaults don't work 'int' object has no attribute      'total_seconds'    When I use time_passed = models.DurationField(default=timedelta()):      * Migrations don't work ValueError: Cannot serialize:      datetime.timedelta(0)    * model default works    So what is the right way to use a default value on duration field or is   this a bug?  
(stackoverflow question: http://stackoverflow.com/questions/29699857/django-durationfield-default-value)
With kind regards, mjonker

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/08e7f94d-60e7-4333-9d2e-ae41a4cfa334%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment