Replies: 5 comments
-
|
I was blocked by this issue too. Adding an instance jumps to the ArtProject add form (if there is only one child model) or the subclass selection screen (if I have ArtProject and ResearchProject). I had to define a proxy model for my parent model and put the proxy in child_models. |
Beta Was this translation helpful? Give feedback.
-
|
Sounds like a note in the docs explaining this limitation might be enough to resolve this issue, along with a recommendation to add a proxy model for the parent to |
Beta Was this translation helpful? Give feedback.
-
|
I would wait for feedback from the maintainers here, so that they can say if this is a bug in the admin (since the examples show using the model directly is possible, as it would be without polymorphic) that can be fixed, or an expected limitation that can’t be avoided for technical reasons. |
Beta Was this translation helpful? Give feedback.
-
|
Verified that this is in fact a bug. A few things going on - the base model is not included in the type selection - but also childless polymorphic models should also work, but those return a 404 |
Beta Was this translation helpful? Give feedback.
-
|
@mrmachine This does work - you just need to include the parent model type in the child_models tuple: class NoChildren(PolymorphicModel):
...
@register(NoChildren)
class NoChildrenAdmin(PolymorphicParentModelAdmin):
child_models = (NoChildren,) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I might be missing something, but it seems like the parent model cannot be created and used directly in the admin. You MUST have at least one child model and you can ONLY create child models in the admin?
What if your parent model is a completely functional base type, and child models are additional and optional? I don't want to create a concrete child subclass just so I can create and edit it in the admin, when it does not require any additional fields.
The very first thing I see in the docs is an example of this, where
Projectappears to be functional on its own, withArtProjectandResearchProjectas subclasses. But these models are not used in the admin integration docs, and the example given uses genericModelA,ModelBandModelCwhere onlyModelBandModelCcan be created and edited in the admin?Beta Was this translation helpful? Give feedback.
All reactions