Django don't generate primary_key

前端 未结 1 1497
广开言路
广开言路 2021-01-28 23:48

I write the migration manually to quickly add to the new environment. When I try to create a new object of the Operator model I get an error about an empty id. I tried to set

相关标签:
1条回答
  • 2021-01-29 00:19

    id is the default model PK so you don't need to define it explicitly.

    If you still want to define it yourself, make it AutoField instead of IntegerField.

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