ArrayModelField我的模型上有一个,Document但是当我尝试将值保存在 上时Admin,它返回['ManagementForm data is missing or has been tampered with']错误。我一直在谷歌搜索这个错误,它只在formsets使用时出现,但我什至没有formsets在这里使用过。我认为我的语法是正确的files,同时拥有model_containerand model_form_class。该类DocumentForm只是带有字段的常用表单类,__all__因此files已包含字段。我错过了什么吗?或者我应该重写我的DocumentForm代码并formsets改用它吗?
class Document(TimestampedModel):
files = models.ArrayModelField(
model_container=DocumentFile,
model_form_class=DocumentFileForm,
default=[],
blank=True,
null=True,
)
class Meta:
abstract = True
class DocumentFile(TimestampedModel):
filename = models.CharField(max_length=250)
file = models.FileField(
_('File'),
null=True,
blank=True,
default=None
)