Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Updated ordering values not getting saved #160

Closed
paddymul opened this issue Jul 16, 2017 · 17 comments
Closed

Updated ordering values not getting saved #160

paddymul opened this issue Jul 16, 2017 · 17 comments

Comments

@paddymul
Copy link

I have an application that uses django-admin-sortable2. At some point the reordering functionality was working correctly. After a series of changes to my application, the reordering functionality is no longer working. Due to migrations and other changes it is not easy to do a git bisect to find the last working state.

As it is, the reordering renders, and inlines are draggable. When I drag an inline to a new position then click save, the database isn't updated.

I have put a pdb.set_trace on the inline model's save() function and I can see that no new value for the ordering parameter are being passed in.

I'm not sure how to debug further.

I am currently running
firefox, django 1.11.3, grapelli, django-admin-sortable2 0.6.13

I was seeing the same non working functionality when running against django 10.5, by disabling grapilli, and on django-admin-sortable2 0.6.4

What can I do to provide you with more debugging information? I realize that this isn't a particularly specific bug report.

Thanks

@timmyomahony
Copy link

I'm also noticing this. Same for inlines. The javascript reordering works but when I save it just reverts to the previous ordering.

@jrief
Copy link
Owner

jrief commented Jul 21, 2017

The field you're using to keep the ordering information is non-unique. Therefore it might be possible that due to some unfinished commits some values might be duplicated. First, please check in the database, if you have some duplicated values or "holes" in that field.

Additionally you can always try to run ./manage.py reorder <app.model> to restore these values.

Since I do not use Grapelli, could you please try with the standard admin theme and check if that error still occurs.

@timmyomahony
Copy link

Running the management command sorted the issue for me

@jrief
Copy link
Owner

jrief commented Jul 21, 2017

would have been great to see the ordering numbers beforehand. Hmm, now it's too late.

@paddymul
Copy link
Author

Is there a command to show the ordering numbers beforehand? I'm going to dump my database so that I can restore it after trying this command.

@paddymul
Copy link
Author

Running the reorder command did not fix this problem for me.

@jrief
Copy link
Owner

jrief commented Jul 23, 2017

@paddymul did you deactivate Grapelli?

@paddymul
Copy link
Author

paddymul commented Jul 23, 2017 via email

@paddymul
Copy link
Author

I created a small django project that reproduces this bug for me. it is based on https://github.com/fasouto/django-starter-template .
$ #activate new virtualenv
$ pip install -r requirements.txt
$ python manage.py migrate
$ python manage.py load_sides
$ python manage.py createsuperuser
$ python manage.py runserver
navigate to http://localhost:8000/admin/bugdemo/sidea/3/change/
and try to save a change of the ordering of ABLinks.

@enoch2110
Copy link

I also experience the same problem as @paddymul does. The standard changelist_view works fine. However, the inline has the problem saving the reordered state. Even when with the reorder management command, the problem is not fixed. Also, when new objects are created after installing adminsortable2, the order field should increment on its own but the inline objects end up with 0 in the order field.

@jrief
Copy link
Owner

jrief commented Jul 25, 2017

Did you Save the parent object after reordering the inline fields?

@meesterguyman
Copy link
Contributor

I think I may have a solution for this. Problem seems to be that when an inline has fields listed, the order field is not being appended to the list, so nothing is submitted on save that would indicate a change in order. Adding the order field to the field list solves this, but this could be done programmatically as well. Submitted a pull request here.

master...meesterguyman:patch-1

@jrief
Copy link
Owner

jrief commented Jul 28, 2017

what's wrong with the current workflow?

On inlines, change the order by dragging. After that save the parent object.
This works all the time and has been tested carefully.

@meesterguyman
Copy link
Contributor

I did not work for me. The drag and drop worked fine, but when I clicked save on anything where fields were listed, it did not save the new order. I had to add the order field to the list explicitly to make it work. But this is something that can be automated by the change I made.

@paddymul
Copy link
Author

@meesterguyman I just tested against that fix, it works for me too. Thanks!!! @jrief can you accept the pull request and push out a new version?

@jrief
Copy link
Owner

jrief commented Aug 11, 2017

@paddymul just merged into current master. Please retest there, then I will release a new version.

@jrief
Copy link
Owner

jrief commented Aug 12, 2017

has been fixed for version 0.6.15

@jrief jrief closed this as completed Aug 12, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants