theatlantic / django-nested-admin

Django admin classes that allow for nested inlines
http://django-nested-admin.readthedocs.org/
Other
727 stars 101 forks source link

Add sorting support for changelist view #100

Open dchapon opened 6 years ago

dchapon commented 6 years ago

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,]
niccolomineo commented 4 years ago

@fdintino really looking forward to this being implemented.

timytomy commented 2 years ago

I also need the feature immediately!!!