Unable to access data in field during migration v1.7c2

28 views
Skip to first unread message

Matthew Meyer

unread,
Aug 8, 2014, 11:51:52 AM8/8/14
to django...@googlegroups.com
I have a model with a FK to  a field called employee. I'm trying to migrate it to django.contrib.auth.models.User. I call a migrations.RunPython command and when I try to access the data in the field before I migrate it and after I have updated the model it is not giving me the correct data. If I access the revert the model changes and access the field from the shell it is correct.  Any idea what is going on?

Daniel Roseman

unread,
Aug 11, 2014, 5:31:24 AM8/11/14
to django...@googlegroups.com
On Friday, 8 August 2014 16:51:52 UTC+1, Matthew Meyer wrote:
I have a model with a FK to  a field called employee. I'm trying to migrate it to django.contrib.auth.models.User. I call a migrations.RunPython command and when I try to access the data in the field before I migrate it and after I have updated the model it is not giving me the correct data. If I access the revert the model changes and access the field from the shell it is correct.  Any idea what is going on?

No, because you haven't shown any code. Remember you need to use the `apps.get_model()` method to get the model as it is before any subsequent changes: could that be the problem?
-- 
DR. 

Matthew Meyer

unread,
Aug 11, 2014, 11:43:40 AM8/11/14
to django...@googlegroups.com
I am using apps.get_model but it seems to be giving me the model as it exists in the models.py and not the model before migrations that is currently part of the database.
Reply all
Reply to author
Forward
0 new messages