Hi Robert, 

Timezones confuse me, maybe Aymeric can answer this one if he has time?

Off topic, your question might be a better fit for the django-users mailing 
list, but perhaps you posted to django-developers intentionally, because 
you are thinking of a bug report?

Wim


On Wednesday, 17 September 2014 01:54:13 UTC+2, Robert Rollins wrote:
>
> I have a legacy database from which my Django application must migrate 
> data into a Django database. The relevant dates fields are actually 
> TIMESTAMP columns in the database, but something (perhaps Django, or 
> python's MySQL driver?) loads these columns as timezone naive datetime 
> objects, rather than integers. So I wrote my migration code under the 
> assumption that the dates coming out of the legacy database are timezone 
> naive.
>
> Unfortunately, now that I'm trying to write tests for this migrator, I 
> can't find any way to load timezone naive datetimes into my test legacy 
> database. I can't use integer timestamps, because the DateTimeField doesn't 
> accept that kind of input (I get a JSON serialization error when I try), so 
> I'm using datetime strings like this: "2014-08-01T00:00:00" in my fixture. 
> But 
> regardless of whether or not I include a UTC offset in the string, the 
> datetime objects that come out of the database during my tests are somehow 
> timezone aware. This causes my code to crash because it calls make_aware(), 
> which throws ValueError('Not naive datetime (tzinfo is already set)'). 
>
> It seems like having USE_TZ = True is forcibly making my fixture dates 
> timezone aware, which I don't want. But USE_TZ will be True during the 
> actual migration, so I can't just turn it off during the tests. So how can 
> I load timezone naive dates into my test database?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/f25965c5-88e9-4f4c-9433-e996ef50611a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to