django ManyToManyField and on_delete

I think the smartest thing to do is use an explicit through table. I realise that you’ve stated you would prefer not to “because this would result in a new table (I’d like to keep the old one).”

I suspect your concern is over losing the data you have. If you’re using South, you can easily “convert” your existing, automatic intermediate table to an explicit one OR, you can create a completely new one, then migrate your existing data to the new table before dropping your old one.

Both of these methods are explained here: Adding a “through” table to django field and migrating with South?

Considering the change you’d like to make to its definition, I’d probably go with the option of creating a new table, then migrating your data over. Test to make sure all your data is still there (and that your change does what you want), then drop the old intermediate table.

Considering that these tables will both only hold 3 integers per row, this is likely to be a very manageable exercise even if you have a lot of houses and owners.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)