Skip to content
This repository has been archived by the owner. It is now read-only.
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
23 lines (15 sloc) 510 Bytes
import zlib
# TODO(davedash): liberate this
def manual_order(qs, pks, pk_name='id'):
Given a query set and a list of primary keys, return a set of objects from
the query set in that exact order.
if not pks:
return qs.none()
objects = qs.filter(id__in=pks).extra(
select={'_manual': 'FIELD(%s, %s)'
% (pk_name, ','.join(map(str, pks)))},
return objects
crc32 = lambda x: zlib.crc32(x) & 0xffffffff
You can’t perform that action at this time.