From f2f5daf83133ff8c5d8f770b6acbfe21e2b3d555 Mon Sep 17 00:00:00 2001 From: Anton Shevchenko Date: Wed, 8 Mar 2017 22:14:48 -0500 Subject: [PATCH] Use 'update_fields' to limit the object's save() method to just the order field, so that other fields are not accidentally overwritten with stale data. --- adminsortable/admin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adminsortable/admin.py b/adminsortable/admin.py index f67505a..ee92501 100644 --- a/adminsortable/admin.py +++ b/adminsortable/admin.py @@ -298,7 +298,8 @@ class SortableAdmin(SortableAdminBase, ModelAdmin): for index in indexes: obj = objects_dict.get(index) setattr(obj, order_field_name, start_index) - obj.save() + # only update the object's order field + obj.save(update_fields=(order_field_name,)) start_index += step response = {'objects_sorted': True} except (KeyError, IndexError, klass.DoesNotExist,