migrate command fails when changing foreign key to a different model

37 views
Skip to first unread message

Shawn H

unread,
Jul 22, 2014, 11:27:11 AM7/22/14
to django...@googlegroups.com
I've looked at  Issue 22485 and Issue 22563, and I'm unsure if my issue is different. I've an employees app with an employee model. I've a tracking app that originally had 3 models each with a foreign key to auth_user. I made a migration for the tracking app to switch those 3 models foreign key to the employees.Employee model. When I try to apply the migration, I get

  File "C:\Virtual\Django17c1\lib\site-packages\django\db\migrations\state.py", line 89, in render
    model=lookup_model,
ValueError: Lookup failed for model referenced by field tracking.PropertyDescription.verified_by: employees.Employee

Stepping through the code, it's failing on line 79 when it's trying to find the employees app. The employees app is not in self.apps for some reason I've not been able to figure out, especially since the employees app is in the global apps.app_configs in migrate.py line 160. The employees app has been migrated.

How should I proceed? Thanks.

Shawn H

unread,
Jul 22, 2014, 11:29:03 AM7/22/14
to django...@googlegroups.com
Forgot to mention that I'm running 1.7RC1

Shawn H

unread,
Jul 23, 2014, 1:49:29 PM7/23/14
to django...@googlegroups.com
May be issue #22944

Shawn H

unread,
Sep 24, 2014, 12:27:02 PM9/24/14
to django...@googlegroups.com
I've upgraded to the 1.7 release version, and I'm still having this issue. While I can (and for my testing purposes have) manually change the database structure and update the foreign keys to point to the correct row in the new table, that kind of defeats the purpose of migrations. I understand that I probably should have used a Data Migration instead of simply letting the default engine generate the migration, but I've already changed the database structure. How can I do migrations in future if I can't get the current one applied? Please help.
Reply all
Reply to author
Forward
0 new messages