Your Ad Here

Sunday, January 8, 2012

Re: Is models.DateTime timezone aware ?

Hi,

I did not read the details of your question, but I can tell you that Django will be timezone aware in 1.4.

https://docs.djangoproject.com/en/dev/releases/1.4-alpha-1/#support-for-time-zones

cheers
Ivo

On Jan 8, 2012, at 0:40 , Matěj Cepl wrote:

> I have in my first Django app this model (selection):
>
> class Post(models.Model):
> # ...
> updated = models.DateTimeField(default=datetime.datetime.now())
> published = models.DateTimeField(blank=True)
>
> When looking at the database dump of the generated database I see that the date is saved as timezone aware:
>
> '2008-07-10 10:00:00+02:00','2008-07-10 10:00:00+02:00'
>
> However, when in the test I try
>
> self.assertEqual(test_entry.updated,
> dateutil.parser.parse(u"2008-07-10T10:00:00+02:00"))
>
> test fails, and I can use only
>
> self.assertEqual(test_entry.updated,
> dateutil.parser.parse(u"2008-07-10T10:00:00"))
>
> What am I missing? Any thoughts, please?
>
> Thank you,
>
> Matěj
>
> --
> http://www.ceplovi.cz/matej/, Jabber: mcepl<at>ceplovi.cz
> GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC
>
> Of all tyrannies, a tyranny exercised for the good of its
> victims may be the most oppressive. It may be better to live
> under robber barons than under omnipotent moral busybodies. The
> robber baron's cruelty may sometimes sleep, his cupidity may at
> some point be satiated; but those who torment us for our own
> good will torment us without end, for they do so with the
> approval of their consciences.
> -- C. S. Lewis
>
> --
> 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.
>

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