Skip to content

nested inlines with SortableTabularInline #257

@maxi-89

Description

@maxi-89

hi people, i had this code:

`

class ReportSectionFieldInline(nested_admin.NestedTabularInline):
    model = ReportSectionField
    extra = 0
    classes = ['collapse']


class ReportSectionInline(nested_admin.NestedTabularInline):
    model = ReportSection
    inlines = [ReportSectionFieldInline]
    extra = 0
    classes = ['secciones-informe']

    class Media:
        css = {
            "all": ("admin/css/reportsection.css",)
        }


class ReportAdmin(nested_admin.NestedModelAdmin):
    list_display = ('id', 'description', 'type_report', 'modulo', 'active',)
    search_fields = ('description', 'type_report',)
    list_filter = ('type_report', 'active',)

    inlines = [ReportSectionInline]

`

so, i want to drag and drop my ReportSectionFields . This is my new code:

`

class ReportSectionFieldInline(SortableTabularInline):
    model = ReportSectionField
    extra = 0
    classes = ['collapse']


class ReportSectionInline(SortableTabularInline):
    model = ReportSection
    inlines = [ReportSectionFieldInline]
    extra = 0
    classes = ['secciones-informe']

    class Media:
        css = {
            "all": ("admin/css/reportsection.css",)
        }


class ReportAdmin(NonSortableParentAdmin):
    list_display = ('id', 'description', 'type_report', 'modulo', 'active',)
    search_fields = ('description', 'type_report',)
    list_filter = ('type_report', 'active',)

    inlines = [ReportSectionInline]

`

but now, i cant see in django-admin-panel the ReportSectionFieldInline i just see ReportAdmin and ReportSectionInline. How can i order this fields when i m working when 2 levels of nested objects?

before:
image

after:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions