def set_orders(self, object_pks):
        objects_to_sort = self.filter(pk__in=object_pks)
        max_value = self.model.objects.all().aggregate(
            models.Max('sort_order')
        )['sort_order__max']
        orders = list(objects_to_sort.values_list('sort_order', flat=True))
        if len(orders) != len(object_pks):
            pks = set(objects_to_sort.values_list('pk', flat=True))
            message = 'The following object_pks are not in this queryset: {}'.format(
                [pk for pk in object_pks if pk not in pks]
            )
            raise TypeError(message)
        with transaction.atomic():
            objects_to_sort.update(sort_order=models.F('sort_order') + max_value)
            for pk, order in zip(object_pks, orders):
                self.filter(pk=pk).update(sort_order=order)
        return objects_to_sort