Can I create model in Django without automatic ID?

前端 未结 3 1345
滥情空心
滥情空心 2021-02-07 11:55

I need a table without a primary key (in Django it was created automatically). So my question is: Can I create a model without an ID/primary key?

I\'m u

3条回答
  •  时光说笑
    2021-02-07 12:09

    No, you can't. Excerpt from the documentation:

    Each model requires exactly one field to have primary_key=True (either explicitly declared or automatically added).

提交回复
热议问题