1

I am developing an application using Django.

In one of the models, I have a field models.DateTimeField('date_of_birth').

I was trying to add few records from the django admin site. Few records were added without any problems. But, the record with a date of birth 1956-01-01 is causing 'Overflow error' with the exception value 'mktime argument out of range'.

Some Googling suggested that the mktime error comes when the date is earlier than the epoch(see here).

The work around suggested there was to use datetime to find the difference from the epoch and save it instead.

Is this not a bug? Is there any workaround instead of converting into the difference?

For the court records, I am using python 2.7, django 1.4.1 and MySQL 5.5 on Windows 7 x64.

Community
  • 1
  • 1
Sundeep
  • 1,536
  • 5
  • 23
  • 35
  • 1
    quick and dirty: create for each date-field an integerfield (day, month, year). On a birthday-field you normaly don't need any calculations - so no real date-object. Btw...you should use `models.DateField` instead of `DateTimeField` – Thomas Schwärzl Oct 18 '12 at 08:14
  • Awesome. Thanks for the suggestion and it worked. Changing it to DateField didn't create any problems plus there are no errors for dates before epoch. I followed from the beginner tutorial and so used the DateTimeField while DateField would have sufficed me. This also reminds me to check all the available models – Sundeep Oct 18 '12 at 16:02
  • However, I am not closing my original question as I want to know how to deal with the DateTimeField as well. – Sundeep Oct 18 '12 at 16:04

0 Answers0