Django migration: making a row not primary key, getting “ProgrammingError: multiple default values”?

后端 未结 1 1342
北荒
北荒 2021-01-18 05:36

I am working with Postgres on a Django app and I want to make a model change, resetting a row so it is no longer the primary key.

This is what my model currently lo

相关标签:
1条回答
  • 2021-01-18 06:16

    Try to use an intermediate migration to achieve this:

    1) Add id = models.IntegerField() to your model. Run makemigrations and then migrate.

    2) Remove primary_key=True from the 'row'-field, and also remove the 'id'-field. Again run makemigrations and migrate.

    0 讨论(0)
提交回复
热议问题