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

'sortable_options' issue (django-tabbed-admin compatibility)

Open SilverFoxA opened this issue 7 years ago • 3 comments

I'm using django-nested-admin & django-tabbed-admin in order to cluster multiple requirements. The packages are really decent, I would like to thank the creators.

I'm facing a few challenges to make both work together. Have checked both of these issues that have been posted #73 & #53

As stated by @fdintino , comment link, all the inlines needs to extend to nested_admin has been considered too, yet the following error.

I shall request, the creators, it would be decent if both of these packages work together seamlessly.

Here's my implementation,

##admins.py

class ProductOptionValueInline(nested_admin.NestedTabularInline):
    model = ProductOptionValue
    extra = 1


class ProductOptionInline(nested_admin.NestedTabularInline):
    model = ProductOption
    inlines = [ ProductOptionValueInline, ]
    extra = 1

class ProductAdmin(nested_admin.NestedModelAdminMixin, TabbedModelAdmin):
    
   .....
    tab_product_option = (
        ProductOptionInline,
    )

   ....
    tabs = [
       ...
        ('Option', tab_product_option),
       ...
    ]

SilverFoxA avatar Mar 11 '19 05:03 SilverFoxA

I'd welcome a PR to add support for django-tabbed-admin, but I won't be working on this any time in the near future—it's hard enough keeping up with new django admin features and their django-grappelli counterparts.

fdintino avatar Apr 08 '19 04:04 fdintino

I think trying to access sortable_options shouldn't fail if not defined and default to disabled:

getattr(self.opts, 'sortable_options', {'disabled': True})

here: https://github.com/theatlantic/django-nested-admin/blob/f1ccc47ce471d1ca4a63f38ba5da2f38b9d32214/nested_admin/nested.py#L193

This because the admin can contain inlines which aren't nested and it wouldn't make sense to add this attribute to all of them. This would be less intrusive. We'll try to send a patch asap.

PS: I'd consider this a bug rather than a feature.

nemesifier avatar Jul 29 '20 18:07 nemesifier