Reputation: 2337
I am trying to add the datetime object of a person. Whenever the birth year is less than year 1942, I get a strange error DataError: unable to parse time
when reading the data back from the DB.
class Person(models.Model):
"""A simple class to hold the person info
"""
name = models.CharField(max_length=100)
born = models.DateTimeField(blank=True, null=True)
Whenever I try to add the born datetime
object of a person born in the year 1929 and then try to read it, It fails.
Let me re-iterate that the data insertion works fine, but fails during the read. I am assuming that something wrong in going on inside the DB.
I did a set of tests and got to know that it fails whenever I add the person born in or before year 1940. It gives DataError: unable to parse time
I am using PostgreSQL.
Any sort of help would be appreciated. Thanks.
Upvotes: 4
Views: 834
Reputation: 2683
The only thing I could come up with here can be found in the PostgreSQL docs. My guess is that Django is storing your date in a "reltime" field, which can only go back 68 years. My calculator verifies that 2009-68 == 1941, which seems very close to what you reported.
I would recommend looking over the schema of your table, by running the following command:
$ python manage.py sql appname
See if the datefield in question is a "reltime" field as I suspect. If this is the case, I'm at a loss about how to change it to a more compatable field without messing everything up.
Upvotes: 6