jazzband / django-polymorphic

Improved Django model inheritance with automatic downcasting
https://django-polymorphic.readthedocs.io
Other
1.66k stars 280 forks source link

Add `PolymorphicInlineModelAdmin.get_child_inlines()` #576

Open piranna opened 9 months ago

piranna commented 9 months ago

The same as PolymorphicParentModelAdmin.get_child_models() allows to dynamically get the child models with base_model.__subclasses__(), I would like to have PolymorphicInlineModelAdmin.get_child_inlines() method that I can overwrite to get the inlines subclasses, and don't need to set them explicitly. This would allows me to have a cleaner code, and also prevent some circular references.

j-antunes commented 9 months ago

Hi! Thanks for opening an issue! Please feel free to open a PR with a possible solution!

piranna commented 9 months ago

I have already done an implementation, just only not fully sure if it's needed at all, once I get sure I'll do a PR. By the moment, I have at https://github.com/jazzband/django-polymorphic/commit/f075aabd4ff705eebeb16676fdd13295cffee8a7 a fix to properly notify with a server side 500 error when there are no configured child models, instead of a non-sense 403 error.

j-antunes commented 9 months ago

Sounds good!

piranna commented 8 months ago

You have the PR at https://github.com/jazzband/django-polymorphic/pull/582, you can review and comment it. I think it works properly, although would like to test it a bit more, specially I would ensure inlines are working properly because I'm having problems with them, I think it's about config on my side instead of a bug but want to ensure it.