Below is my admin form
Class RequestedAreaInilne(admin.StackedInline):
model = RequestedArea
fields = ("area", "building")
class BuildingAdmin(admin.ModelAdmin):
fields = ("special_access", "user_id", etc ....)
inlines = (RequestedAreaInline,)
While saving the BuildingAdmin form I need to validate inline form (ie RequestedAreaInilne). Validation should happen based on the value from the BuildingAdmin form field .
To add more information ,
special_access of the BuildingAdmin is boolean field(True or False). If the user selection is True , I want to check if they have entered value for RequestedAreaInline. If it is not entered I need show them a message that "You should enter data for this"
I tried doing the validation in save_formset()
. But I am not getting inline field.
How can I validate the inline formset based on parent form