Django 1.9 drop foreign key in migration

前端 未结 3 828
Happy的楠姐
Happy的楠姐 2020-12-30 09:13

I have a Django model that has a foreign key to another model:

class Example(models.Model)
   something = models.ForeignKey(SomeModel, db_index=True)
         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-30 09:18

    As of Django 2.0, changing your field to models.ForeignKey(db_constraint=False, db_index=False, ...) will generate a migration that does ALTER TABLE DROP CONSTRAINT and DROP INDEX IF EXISTS, which appears to be exactly what you want.

提交回复
热议问题