mirror of
https://github.com/jazzband/django-admin-sortable.git
synced 2026-04-11 10:21:08 +00:00
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.
This commit is contained in:
parent
99530d3ba4
commit
f2f5daf831
1 changed files with 2 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue