在我决定使用AutoField将优先级字段作为主键之后class Alrule(models.Model):AssertionError: A model can't have more than one AutoField.我的理解是优先级字段之前被设置为AutoField,并且它没有被删除。migrations.AlterField(
mode
\models\fields\__init__.py", line 919, in contribute_to_class
"A model can't have more than one AutoFieldAssertionError: A model can't have more than one AutoField.
. # question here
我希望Widget.sequence_id像AutoField一样工作(也就是,自动提供一些唯一的东西,通常会递增1),但作用域是单个Widget.owner。我查阅了AutoField和unique_together上的文档。我找到了,但这并不是我想要的。我在djangopackages.com上没有看到任何可以解决我的问题的东西,尽管我可能会错过它。