Skip to content

Commit 61f0e64

Browse files
committed
Add comment re: ordering by PK
1 parent 0fd78b9 commit 61f0e64

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

netbox/netbox/api/viewsets/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ def create(self, request, *args, **kwargs):
180180
# to ensure related objects are prefetched.
181181
if bulk_create:
182182
instance_pks = [obj.pk for obj in serializer.instance]
183+
# Order by PK to ensure that the ordering of objects in the response
184+
# matches the ordering of those in the request.
183185
qs = self.get_queryset().filter(pk__in=instance_pks).order_by('pk')
184186
else:
185187
qs = self.get_queryset().get(pk=serializer.instance.pk)

0 commit comments

Comments
 (0)