i'm interested in making use of admin inlines for polymorphic models.
i saw some initial discussion about integrating the admin at
https://groups.google.com/group/django-polymorphic/browse_thread/thread/84290fe76c40c12d
but as far as i know, no one's written anything yet.
Here are some thoughts about possible inline solutions. To extend the
example in the original discussion, let's say that the Base class has
an FK to an OtherModel class. i'd like to add an inline formset to
OtherModel's ModelAdmin where i can manage instances of ModelA and
ModelB, primarily because at some point i want to manage the order of
those instances in relation to OtherModel.
Seems to me there are two tasks- 1) having each inlined instance
connected to the appropriate ModelForm, and 2) adding functionality to
the "add item" link so it can be determined whether an instance of
ModelA or ModelB should be created.
We can make an inline using the Base model class, the queryset of
which would most likely return ModelA and ModelB instances for already
created instances, but the ModelForm used in the inline for the Base
class obviously won't reflect the fields unique to ModelA and ModelB.
For this reason, it seems that an inline_formset_factory is not
sufficient to do this. Also, even if we could render each instance's
form somehow, only the "stacked" template will suffice, because the
"tabular" style template can't handle instances with differing fields.
My particular use case allows for another scenario, though. If we can
simply extend the default inline and template for the Base model so
each instance has an "edit" link to the actual instance's model form
(as a popup, probably), then we can still used a "tabular" template
(which is better for ordering instances) by adding an additional
column, and keep most of the admin's inline logic in tact. All we
really need to do is make some sort of hook so the related instance's
edit view can be reached.
That still leaves the second problem, though, where the "add item"
link is insufficient. i suppose this link's behavior could be
overridden so it shows a prompt where ModelA and ModelB are listed,
the user chooses one, and the appropriate edit form shown. This idea
isn't as developed.
Thoughts?