Hi Robert,

On 17 sept. 2014, at 01:54, Robert Rollins <coredumper...@gmail.com> 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, you're running into a known and documented limitation of time 
zone support in Django:
https://docs.djangoproject.com/en/dev/ref/databases/#timestamp-columns

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


Would it be possible to:
- use USE_TZ = False during the migration process,
- convert datetimes to the proper timezone while migrating,
- then switch back to USE_TZ = True?

Based on my understanding of your situation, I believe this is the easiest path 
if you want to use the ORM.

Alternatives include:
- pull data with raw SQL queries -- cursor.execute(...) -- and insert it into 
the main database through Django,
- export data to a CSV file and re-import that.

I hope this helps,

-- 
Aymeric.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" 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/414F70F4-01F2-41B8-A836-42596DAAA8C3%40polytechnique.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to