loading initial fixture of an app before another

21 views
Skip to first unread message

Michael Palumbo

unread,
Aug 4, 2012, 5:24:13 AM8/4/12
to django...@googlegroups.com
Hi,

I have initial fixtures (initial_data.json) for several apps.
The model A of App1 references the model B of App2.
I use natural keys to reference it. 
So when I sync the DB, Django tries to make a query on modelB.

However, it appears that the fixtures of my App1 are installed before the fixtures of my App2.
It then fails because it cannot get the modelB.

I would like the contrary: to install fixtures from App2 before.

I tried a natural_key.dependencies on the naturel_key method of the model A in my App1 but it does not work. (https://docs.djangoproject.com/en/dev/topics/serialization/#dependencies-during-serialization)
    def natural_key(self):
        return (self.url,)
    natural_key.dependencies = ['app2.modelB']

Any idea?

Thanks
Reply all
Reply to author
Forward
0 new messages