Skip to content

Fix compatibility with django-polymorphic 4.6 (complete)#280

Open
djmaze wants to merge 1 commit intotheatlantic:masterfrom
djmaze:fix/django-polymorphic-4.6-compatibility
Open

Fix compatibility with django-polymorphic 4.6 (complete)#280
djmaze wants to merge 1 commit intotheatlantic:masterfrom
djmaze:fix/django-polymorphic-4.6-compatibility

Conversation

@djmaze
Copy link
Copy Markdown

@djmaze djmaze commented Jan 30, 2026

As the author of #279 is not responsive, here is a new PR which should fix the remaining problems.

@nattyg93
Copy link
Copy Markdown

@fdintino Any chance we can get this merged and released? With Django 4.2 reaching EOL, this is a blocker for upgrading to Django 5.2 when using django-polymorphic and django-nested-admin.

@fdintino
Copy link
Copy Markdown
Member

The reason I haven't merged this yet is that the logic here is very different than what was in _get_inheritance_relation_fields_and_models.

https://github.com/jazzband/django-polymorphic/blob/d2f9ca27c0bd0ca522e80266f5205a760d7f74d2/src/polymorphic/models.py#L342-L390

I would be more inclined to merge this if the logic was functionally identical. At the very least it needs to be using __subclasses__ since this variable is meant to include child models only. The model parents are already accounted for in a different variable. I think this might be functionally equivalent:

model_cls = self.formset.model.__class__
sub_models = [
    sub_cls
    for sub_cls in model_cls.__subclasses__()
    if model_cls in sub_cls._meta.parents
]

@djmaze djmaze force-pushed the fix/django-polymorphic-4.6-compatibility branch from 254b04d to ac837ce Compare April 15, 2026 14:47
@djmaze
Copy link
Copy Markdown
Author

djmaze commented Apr 15, 2026

The reason I haven't merged this yet is that the logic here is very different than what was in _get_inheritance_relation_fields_and_models.

@fdintino Okay, sorry, I was not knowledgeable in this codebase. I just tried to implement your suggested approach, maybe it is more correct now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants