django-nested-admin icon indicating copy to clipboard operation
django-nested-admin copied to clipboard

Add sorting support for changelist view

Open dchapon opened this issue 7 years ago • 2 comments

Django-suit was great...

Using django-suit and SortableModelAdmin/SortableTabularInline, it is possible to sort objects in the admin interface's changlelist view and sort inlines, provided that a sortable attribute is provided ('order' by default in django-suit).

class CustomServiceProductBindingInline(suit.admin.SortableTabularInline):
    model = Product.bound_services.through
    verbose_name = _("attached services")
    sortable = 'order'

class ProductModelAdmin(suit.admin.SortableModelAdmin):
    model = Product
    sortable = 'order'
    inlines = [CustomServiceProductBindingInline,]

But...

But django-suit cannot handle nested inlines, so I integrated properly the django-nested-admin application in my web app and it works like a charm. I had to switch my ModelAdmins from suit.admin.SortableModelAdmin to nested_Admin.NestedModelAdmin and switch my inlines from suit.admin.SortableTabularInline to nested_Admin.NestedTabularInline...

and the nested inlines work fine....

The problem is : with django-nested-admin, my ModelAdmin cannot be sorted in the changelist view anymore ! Is there a way to implement it ? Is this a compatibility issue with django-suit ? Or simply is it not implemented in django-nested-admin ?

class CustomServiceProductBindingInline(nested_admin.NestedTabularInline):
    model = Product.bound_services.through
    verbose_name = _("attached services")
    sortable_field_name = "order"


class ProductModelAdmin(nested_admin.NestedModelAdmin):
    model = Product
    sortable_field_name = 'order'
    sortable = 'order'  # Does not work anymore
    sortable_field_name = "order"  # Apparently ignored too...
    inlines = [CustomServiceProductBindingInline,]

dchapon avatar May 28 '18 11:05 dchapon

@fdintino really looking forward to this being implemented.

niccolomineo avatar Nov 12 '20 23:11 niccolomineo

I also need the feature immediately!!!

timytomy avatar Jun 23 '22 16:06 timytomy