我无法在我的管理站点中覆盖 ModelAdmin 对象的 TabularInline 内联表单集。我知道您应该有一个与 TabularInline 对象关联的模型,但我不确定如何在用于生成表单集的表单对象上指定它。使用下面的代码,我得到“'AppAssetInline.formset' 不继承自 BaseModelFormSet。”
class AppAssetForm(forms.ModelForm):
model = App.assets.through
primary = forms.BooleanField()
uuid = forms.CharField()
class AppAssetInline(admin.TabularInline):
model = App.assets.through
AssetFormset = formset_factory(AppAssetForm)
formset = AssetFormset
class AppAdmin(admin.ModelAdmin):
inlines = [AppAssetInline,]