Skip to content

Commit

Permalink
fix: maintain order of insertions into m2m relationship tables (ansib…
Browse files Browse the repository at this point in the history
  • Loading branch information
pb82 authored Sep 17, 2024
1 parent ef8cb89 commit af900c8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion awx/main/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ def _update_m2m_position(self, sender, instance, action, **kwargs):
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()
Expand Down

0 comments on commit af900c8

Please sign in to comment.