Open CelestialStreamer opened 2 years ago
Ok, will have a look for the next release.
TL;DR A quick workaround is using a custom PolymorphicParentModelAdmin
class like so:
class CustomPolyParentAdmin(PolymorphicParentModelAdmin):
@property
def change_list_template(self):
return "admin/change_list.html"
@admin.register(models.Parent)
class ParentAdmin(SortableAdminMixin, CustomPolyParentAdmin):
child_models = (models.ChildA, models.ChildB)
This should work assuming you are not using any custom templates, in which case you would have to specify the path to your custom template instead of `"admin/change_list.html". Unsure what you need to do if you are using multiple mixins, as that gets confusing.
The issue stems from the fact that the property change_list_template
from PolymorphicParentModelAdmin
returns a list of templates instead of a single template. I believe this is done to allow custom templates based on the child object type. From django-polymorphic docs:
It extends the template lookup paths, to look for both the parent model and child model in the admin/app/model/change_form.html path.
Which is a supported feature of SimpleTemplateResponse. I believe the issue was introduced in #316
Brand new, minimal django project. On admin pages for parent polymorphic model with sortable admin mixin gives error:
models.py
admin.py
Versions
Stuck
I don't know if
SortableAdminMixin
is the culprit orPolymorphicParentModelAdmin
. #196 does not work for me. I addedSortableAdminMixin
toChildAAdmin
andChildBAdmin
orChildAdmin
and I still get the same error.