Prometheus
Prometheus

Reputation: 33625

Create FK relationship during migration

On migration I need to create a relationship between activity and organisation where organisation has not been created. Below is what I have so far. I now need so somehow set the default= to the new organisation created? i.e.

field=models.ForeignKey(related_name='activities', to='orss.Organisation' default=temp_org_just_created

Is this possible? If so how?

Upvotes: 1

Views: 77

Answers (1)

knelson
knelson

Reputation: 126

There are two types of migrations, schema and data migrations. You'll need to run your schema migration first, and the data migration afterwards.

Documentation

Upvotes: 1

Related Questions