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

Inheritance model doesn't update sort.

Open portedison opened this issue 2 years ago • 2 comments

With inheritance, e.g. Writing, Event, etc all inheriting from Content. Creating Writing doesn't trigger (or implement) the admin mixin applied to the Content model. They add with the default value '0'. And subsequently can't be updated, as there are too many with the value of '0'. How should we trigger this to resort (similar to the management command) after save?

class Content(models.Model):
      sort_order = models.PositiveIntegerField(default=0, db_index=True)
      ...

class Writing(Content):
      ....

portedison avatar Sep 05 '22 22:09 portedison

Is this the idea of PolymorphicSortableAdminMixin- https://github.com/jrief/django-admin-sortable2/blob/3c7c8c34a07c8d522d8f6c5216f0e0a6180730a9/adminsortable2/admin.py#L419

portedison avatar Sep 05 '22 23:09 portedison

Could you please fork the project and create a polymorphic model where this problem occurs. For instance by separating Book from Magazin (a magazin doesn't have an author but a publisher). I then can look for a solution and use that as a starting point to implement a unit test.

jrief avatar Sep 06 '22 17:09 jrief