I’ve got a model Child inheriting from a (non abstract) model Parent.
For a given instance parent of Parent, how can I know if it’s a Child?
If it is,
parent.child
returns the child, but otherwise it returns a DoesNotExist exception.
Is a try/except the only way to check that?
Thanks
jul
# EDIT
I’ve just find the same question here:
Distinguishing parent model's children with Django inheritance.
And the answer is….
hasattr(parent, 'child')
I’ve just find the same question here:
Distinguishing parent model's children with Django inheritance.
And the answer is….