django多重嵌套
Sometimes you want to validate only parts of a Django form. A use case for this would be a user profile. A user may have an extensive user profile, but sometimes you only want to validate a subset of the form fields, e.g. the city and the phone number, when providing a profile edit form. On another page you might want to offer a username change. If you try to validate one of those forms using POST data for the provided fields only, the validation will fail because there are other mandatory fields. In that case, Python’s support for multiple inheritance may suit you.
有时您只想验证Django表单的一部分。 一个用例是用户个人资料。 用户可能具有广泛的用户个人资料,但有时在提供个人资料编辑表单时,您只想验证表单字段的子集,例如城市和电话号码。 在另一页上,您可能想更改用户名。 如果您尝试仅对提供的字段使用POST数据来验证其中一种表格,则验证将失败,因为还有其他必填字段。 在这种情况下,Python对多重继承的支持可能适合您。
多种形式继承 (Multiple form inheritance)
First, define a form for all the form field subsets you might need to validate.
首先,为您可能需要验证的所有表单域子集定义一个表单。
class class FormAFormA (( forms