access parent form's cleaned_data from inline form clean()

依然范特西╮ 提交于 2020-02-02 02:59:08

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/10183066/access-parent-forms-cleaned-data-from-inline-form-clean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!