def manual_order(qs, pks, pk_name='id'):
    if not pks:
        return qs.none()
    return qs.filter(id__in=pks).extra(
        select={'_manual': 'FIELD(%s, %s)' % (pk_name,
                                              ','.join(map(str, pks)))},
        order_by=['_manual'])
Given a query set and a list of primary keys, return a set of objects from
dataset/ETHPy150Open mozilla/addons-server/src/olympia/amo/models.py/manual_order