Hello.
I've got the same model in two projects and want to copy data from one to 
another using model meta 'db_table' option:


my_model_original_table_name = MyModel._meta.db_table
MyModel._meta.db_table = 'old_project_table_name' 

old_objects = MyModel.objects.using('old_project_data_base').values('name')
old_objects = list(old_objects)

MyModel._meta.db_table = my_model_original_table_name

for old_object in old_objects:
    new_object, created = 
MyModel.objects.update_or_create(name=old_object['name'])


Old data retrieving works great, but when i try to execute last statement i 
get:
"django.db.utils.ProgrammingError: missing FROM-clause entry for table 
"old_project_table_name""

I tied to fetch data at the last stage instead of updating/creating 
(MyModel.objects.all()) and get the same error.
The sql-query created by ORM is:
SELECT "old_project_table_name"."name" FROM "new_project_table_name"

Why is it so?

I am using django 1.8.6 and PostgreSQL 9.4.5
Django 1.7.* work fine.


Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1e1ceea2-20ac-44f9-af93-e71eaf3b90b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to