I have a parent class and a child class which inherits parent. In a child class object, I need to differentiate between parent class fields and child class fields.
Is this information available? If so, where. Need solution in Python, specifically Django.
Consider such a parent and child model:
To make a function that determines if a field is defined in one of the parent, we should iterate over the
class.__bases__, and trybaseclass._meta.get_fieldfor eachNow:
is_attr_defined_on_parent(Child, 'parent_field')returns True,is_attr_defined_on_parent(Child, 'child_field')returns False.