I have something like this:
class A(Model):
b = OneToOneField('B', related_name='a')
class B(Model):
pass
But for obvious reasons I think my models would be better structured like this:
class A(Model):
pass
class B(Model):
a = OneToOneField('A', related_name='b')
Unfortunately the models are already in production. I'm familiar with makemigrations
/migrate
and have had a look through the migration files in the migrations
directory. I think what I want is to:
- create an
a
field onB
, changingrelated_name='something_else'
- have it initialized using the reverse relation
something_else
- remove the
b
field onA
.
How can I initialize a field in a migration in such a way?