В django admin Я пытаюсь создать новую запись, но поля в встроенных формах выдают ошибки, говоря, что они необходимы, даже если я не хочу создавать новый встроенный.
модели:
class Attribute(models.Model):
name = models.CharField(choices=ATTRIBUTE_CHOICES, max_length=max_choice_len(ATTRIBUTE_CHOICES))
amount = models.PositiveIntegerField()
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey()
def __str__(self):
return f'{self.name} {str(self.amount)}'
class Item(models.Model):
...
attributes = GenericRelation(Attribute)
admin:
class AttributeInline(GenericTabularInline):
model = Attribute
extra = 0
class ItemAdmin(admin.ModelAdmin):
inlines = [AttributeInline]
class Meta:
model = Item
admin.site.register(Item, ItemAdmin)