Skip to content

Instantly share code, notes, and snippets.

@chriskief chriskief/query.py
Last active Oct 19, 2018

Embed
What would you like to do?
ids = [9, 8, 1, 2, 7, 3]
results = Model.objects.filter(id__in=ids).extra(
select={'manual': 'FIELD(id,%s)' % ','.join(map(str, ids))},
order_by=['manual']
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.