Reputation: 41
I am trying to use the DateTimeField in a postgresql model. I have set time zones to be true in the settings and the model field is:
pickupTime = models.DateTimeField(default=datetime.now())
However, when I run python manage.py migrate there is an error:
django.db.utils.ProgrammingError: cannot cast type time without time zone to timestamp with time zone
I have tried different variations for the DateTimeField default value like:
models.DateTimeField(default=timezone.now)
models.DateTimeField(auto_now_add=True)
models.DateTimeField(auto_now_add=True, auto_now=False)
but the error is still the same. What am I missing?
Upvotes: 0
Views: 2602
Reputation: 1067
Try this:
pickupTime = models.DateTimeField(default=datetime.now)
It should work.
Upvotes: 1