[Answer]-Django/Python Chain and Sort Querysets

1👍

To solve your immediate problem – assuming that’s itertools.chain, chain takes multiple iterables. Use chain(*count_items) to expand your list of querysets.

But you can save yourself some trouble by using InventoryDetails.objects.filter(inventory_location__in=inv_locations).order_by('epc').distinct() – that’ll do the sorting and uniquing in the database rather than you doing it in your view.

Leave a comment