I am working on task, where for multiple inlines, i have to check if they are valid or not and then check if there is certain condition which 2 inlines follow, ie if there is value/data in both formset then throw error.
in django there is no direct way to check the django formsets cross validation and the solution i come up with was copying _changeform_view
method from codebase, and modifying all_valid
function in it (imported from from django.forms.formsets import DELETION_FIELD_NAME, all_valid),
in my opinion if we include all_valid
method in BaseForm
or ModelAdmin
class itself and from there use this , in _changeform_view
method, then we can have more control on formsets and there cross validations.
and with a little modification of all_valid
function we can just add a bunch of validation on formsets and among themself itself.