This also replaces the PolymorphicInlineModelAdmin.get_get_child_inline_instance()
and BasePolymorphicModelFormSet._construct_form() lookup with UnsupportedChildType
(cherry picked from commit cafaf95f06)
This change fixes an issue where django-polymorphic raises a
`ParentAdminNotRegistered` exception when you register an admin for a
child model ancestor, but not for the root ancestor as pointed to by
the `polymorphic_ctype` field. This error occurs only when you *Save*
the child model detail form, not when you *Save and continue* on that
same form.
This situation occurs for us when using django-fluent-pages version
1.0.1 which has an intermediate `Page` model registered with a parent
admin to show the pages listing. The existing `_get_parent_admin` method
expects an admin to be registered for the root `UrlNode` model pointed
to by the `polymorphic_ctype` field.
This fix uses a potentially naive and slow brute-force approach where
it walks up the class hierarchy and checks whether a parent admin is
registered for each ancestor model, unless/until it finds one.
See also https://github.com/ic-labs/django-icekit/issues/31/
When the base model also serves as child model, the flow no longer
points to the child admin, but returns `self` instead. Either every user
of `_get_real_admin()` should detect this, or we return the super method
as convenience.