jrief / django-admin-sortable2

Generic drag-and-drop ordering for objects in the Django admin interface
https://django-admin-sortable2.readthedocs.io/en/latest/
Other
774 stars 180 forks source link

Fix #316: Allow combining admin mixins by storing original change_list_template #317

Closed PetrDlouhy closed 2 years ago

PetrDlouhy commented 2 years ago

Fix #316

The problem is caused by django-admin-sortable2 ignoring the value of change_list_template property from previous mixins. This PR stores renames the changoe_list_template to sortable_change_list_template to allow access to the original property value. Then it sets the new value in __init__, but uses the original value as base template for admin/change_list.html so that overriding of these templates is chained together.

PetrDlouhy commented 2 years ago

I have added test for the new behavior (which also tests, that GET will put the JSON values in the response). I rebased to 2.0.2, which is the last version with passing tests, but I still got timeouts. I don't know what is the problem, but I expect it is not the new code.

@jrief Could you please try to remember or test this code in your environment to determine what caused the "it didn't work" problem? I am willing to fix all the problems, but right now I couldn't think how the mechanism I have used can fail.

Or if somebody else could test this to confirm/disprove the problems, I would be really glad. I am using this on different project than the original PR and it works fine.

jrief commented 2 years ago

Unit tests run on my local machiche. However, for reasons unknown to me, they fail on GH actions. I have to investigate further. I'll merge this solution soon. Thanks for investigating.

jrief commented 2 years ago

@PetrDlouhy I used your pull request as a starting point but implemented it in a slightly simpler way. I also created a unit test to check if the template is overridden. Please have a look at the HEAD of the repository.

PetrDlouhy commented 2 years ago

@jrief The new version seems to work nicely. Thank you very much.