You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromadminsortable2.adminimportSortableAdminMixinfromdjango.contribimportadminfrompolymorphic.adminimportPolymorphicChildModelAdmin, PolymorphicParentModelAdminfrom . importmodelsclassChildAdmin(PolymorphicChildModelAdmin):
"""Base admin class for all child models"""@admin.register(models.ChildA)classChildAAdmin(ChildAdmin):
base_model=models.ChildA@admin.register(models.ChildB)classChildBAdmin(ChildAdmin):
base_model=models.ChildB@admin.register(models.Parent)classParentAdmin(SortableAdminMixin, PolymorphicParentModelAdmin):
child_models= (models.ChildA, models.ChildB)
Versions
django==4.0
django-admin-sortable2==2.1.2
django-polymorphic==3.1.0
Python=3.10.1
Stuck
I don't know if SortableAdminMixin is the culprit or PolymorphicParentModelAdmin. #196 does not work for me. I added SortableAdminMixin to ChildAAdmin and ChildBAdmin or ChildAdmin and I still get the same error.
The text was updated successfully, but these errors were encountered:
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.
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.The text was updated successfully, but these errors were encountered: