Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SortableInlineAdminMixin does not work with nested_admin NestedTabularInline #131

Closed
smipi1 opened this issue Oct 3, 2021 · 2 comments
Closed

Comments

@smipi1
Copy link

smipi1 commented Oct 3, 2021

I have tried creating a doubly-nested 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 and here.

It appears that inheriting both the django and nested_admin classes prevents the adminsortable2 exception, but this breaks the nested 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-inline 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
@smipi1
Copy link
Author

smipi1 commented Oct 3, 2021

I also logged an issue with the adminsortable2 project so that both projects are aware of the incompatibility.

@smipi1
Copy link
Author

smipi1 commented Oct 3, 2021

Wrong project... Sorry!

@smipi1 smipi1 closed this as completed Oct 3, 2021
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

No branches or pull requests

1 participant