2

In my settings.py I use America/Chicago as my default TIME_ZONE variable. I am going to update to django 1.4 soon. As a MySql user, I would like to know if there is anything I need to know before the upgrade.

The reason for upgrading to 1.4 is, of course, the timezone support that django 1.4 offers and it is very essential to what I am doing at the moment. I noticed that MySQL timestamp objects are not in UTC format (my models all use DateTimeField()).

What am I supposed to do?

xpanta
  • 8,124
  • 15
  • 60
  • 104

1 Answers1

1

I am dealing with this upgrade now and unfortunately there isn't a clear path to follow. The django 1.4 migration guide instructs that the values in the database need to be converted but that this isn't possible deterministically!

So you will have to convert the values but know that in some cases around daylight savings time transitions the conversion will not be perfect. I plan to use the new make_aware(value, timezone) function in django 1.4 to convert the datetime values and I will handle the exceptions by retrying the conversion after adding an hour to the input datetime.

Here are specific details and lots more sample code for converting local time to UTC in python

Community
  • 1
  • 1
David Wheaton
  • 608
  • 6
  • 11
  • Thank you. I already manage to do the upgrade. It took my some days because some modules (like django-notification or django-avatar, or even South) needed modifications/updates, too. I also had some problems using the new template timezone filters so I wrote mine. In my template filter I also use a method similar to the one you suggest. I found make_aware() and make_naive() to be very usefull. To sum up the migration was not very easy. It took me some time. I had to make some changes in the model, too. – xpanta Apr 26 '12 at 15:25