SortableInlineAdminMixin does not work with nested_admin NestedTabularInline
I have tried creating a doubly-nested sorted inline admin using:
from django.contrib import admin
from translated_fields import TranslatedFieldAdmin
from nested_admin import NestedStackedInline
from adminsortable2.admin import SortableInlineAdminMixin
class LineInline(TranslatedFieldAdmin, SortableInlineAdminMixin, NestedTabularInline):
model = Line
extra = 0
class StanzaInline(TranslatedFieldAdmin, SortableInlineAdminMixin, NestedTabularInline):
model = Stanza
inlines = [
LineInline,
]
extra = 0
@admin.register(Poem)
class PoemAdmin(TranslatedFieldAdmin, NestedModelAdmin):
inlines = [
StanzaInline,
]
adminsortable2 throws an ImproperlyConfigured error (and rightfully so):
Class poems.admin.<class 'poems.admin.StanzaInline'> must also derive from admin.TabularInline or admin.StackedInline
nested_admin derives NestedTabularInline from InlineModelAdmin as can be seen here.
It appears that inheriting both the django and nested_admin classes prevents the adminsortable2 exception, but this breaks the nested admin inlines in the admin page:
class LineInline(TranslatedFieldAdmin, SortableInlineAdminMixin, NestedTabularInline, admin.TabularInline):
...
class StanzaInline(TranslatedFieldAdmin, SortableInlineAdminMixin, NestedTabularInline, admin.TabularInline):
Figuring out exactly how to work around this is way above my experience and skill, but I am very eager to assist in any way I can.
Is there a way to get the django-nested-admin and django-admin-sortable2 plugins to work together?
I'm using:
Django==3.2.3
django-admin-sortable2==1.0.2
django-nested-admin==3.3.3
django-translated-fields==0.11.2
I also logged an issue with the django-nested-admin project so that both projects are aware of the incompatibility.
I never worked with django-nested-admin, so I can't really drill down on the problem. Here is my hint on how to solve it: If you somehow can find out if your for is a NestedTabularInline, than I assume that you have to provide a special template for it. Use that template as a starting point with the additional sortable features and return it in https://github.com/jrief/django-admin-sortable2/blob/master/adminsortable2/admin.py#L571
If you want me to implement this as a sponsored feature, please contact me on my private email address.