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
770 stars 181 forks source link

order starts with -1 #412

Closed sigma-plus closed 3 weeks ago

sigma-plus commented 3 weeks ago

when drag with SortableAdminMixin in Admin List , the post request is "updatedItems:[["9", -1], ["8", 0]]" . The order field starts with "-1", which is invalid with PositiveIntegerField.

Django Version: 5.1.2

jrief commented 3 weeks ago

could you please give me a receipt on how to reproduce this using the provided testapp.

sigma-plus commented 3 weeks ago

I use the demo in your docs. when I add books with commands as below: image

the Admin List can not reorder, because the new order is -1, which cause 400 Bad Request

but when I use admin form page to add books , it works.

jrief commented 3 weeks ago

If you create the objects yourself, you then of course have to provide the initial data yourself.

sigma-plus commented 3 weeks ago

If you create the objects yourself, you then of course have to provide the initial data yourself.

thanks for your reply. but it's wired when you cannot reorder the admin list items when these items has equal order value 0.