I have a class with many fields:
class Parent(models.Model): id = models.AutoField(primary_key=True) ... many more fields
and I create a subclass
class Child(Parent): other_field = models.CharField(max_length=512, blank=True, null=True) date_featured = models.DateField()
After I migrate and create a Child object in the admin I get
duplicate key value violates unique constraint "parent_pkey" DETAIL: Key (id)=(5) already exists.
I've seen some similar questions that suggest that you modify the database but I can't easily do that. Do I need to change the id of the subclass?
https://stackoverflow.com/questions/67377032/django-subclass-model-gives-duplicate-key-value-violates-unique-constraint-on May 04, 2021 at 07:38AM
没有评论:
发表评论