mirror of
https://github.com/ansible/awx.git
synced 2026-01-10 15:32:07 -03:30
fix: maintain order of insertions into m2m relationship tables (#15536)
This commit is contained in:
parent
ef8cb892cb
commit
af900c8370
@ -1039,7 +1039,7 @@ class OrderedManyToManyField(models.ManyToManyField):
|
||||
descriptor = getattr(instance, self.name)
|
||||
order_with_respect_to = descriptor.source_field_name
|
||||
|
||||
for i, ig in enumerate(sender.objects.filter(**{order_with_respect_to: instance.pk})):
|
||||
for i, ig in enumerate(sender.objects.filter(**{order_with_respect_to: instance.pk}).order_by('id')):
|
||||
if ig.position != i:
|
||||
ig.position = i
|
||||
ig.save()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user