I have a main form that has an inline-form. Is it possible to access the main form's cleaned_data from the inline-form's clean function?
Here is why I am asking.
The main form has a field to define if a property is for-sale or to lease. The inline form then displays either a sale price field or fields for the lease amount and deposit. I am trying to validate that if the property is for sale, then the lease and deposit fields should be empty.
I can do this in a view for the frontend interface, but is it possible to be done in forms.py for both the frontend and the admin?
No, these forms are separate objects and are completely unaware of each other. But you are providing same data
to all forms, so you should be able to check fields from self.data
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With