我很惊讶这个问题以前没有被问过(或者至少我没有找到它)。我有一个带有两个内联表单集的 ModelAdmin,并且想在它们之间进行交叉验证。
class PublicationGroupInlineFormSet(BaseInlineFormSet):
def clean(self):
# Here I validate the PublicationGroupInlineFormSet
class PublicationGroupInline(StackedInline):
model = PublicationGroup
formset = PublicationGroupInlineFormSet
class PublicationProjectInlineFormSet(BaseInlineFormSet):
def clean(self):
# Here I validate the PublicationProjectInlineFormset
class PublicationProjectInline(StackedInline):
model = PublicationProject
formset = PublicationProjectInlineFormSet
class PublicationAdmin(ModelAdmin):
inlines = (PublicationProjectInline, PublicationGroupInline)
admin.site.register(Publication, PublicationAdmin)
问题很简单,答案可能不会。如何在两个表单集之间进行交叉验证?谢谢!