I\'ve got a model
class Category(models.Model):
title = models.CharField(...)
entry = models.ManyToManyField(Entry,null=True,blan
I'd do it in the following way:
Add the CategoryEntry
class to the model, and do an auto schema migration. This will add an empty table containing the properties of CategoryEntry
. To be noted, the older M2M table remains untouched since through='CategoryEntry'
has not yet been added.
Do a data migration to copy all data from the existing M2M table to the table created in step 1. To do so, run the datamigration
command, and edit methods forward()
and backward()
in the auto generated migration script accordingly.
Now add through='CategoryEntry'
part (just the way you wanted), and do a schemamigration. this will drop the old M2M table.