mirror of
https://github.com/ansible/awx.git
synced 2026-03-06 11:11:07 -03:30
fix: maintain order of insertions into m2m relationship tables (#15536)
This commit is contained in:
@@ -1039,7 +1039,7 @@ class OrderedManyToManyField(models.ManyToManyField):
|
|||||||
descriptor = getattr(instance, self.name)
|
descriptor = getattr(instance, self.name)
|
||||||
order_with_respect_to = descriptor.source_field_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:
|
if ig.position != i:
|
||||||
ig.position = i
|
ig.position = i
|
||||||
ig.save()
|
ig.save()
|
||||||
|
|||||||
Reference in New Issue
Block a user