Created
May 28, 2012 22:28
-
-
Save ltvolks/2821469 to your computer and use it in GitHub Desktop.
Combine results from separate Django querysets linearly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Combine results from separate Django querysets linearly | |
| from itertools import chain | |
| good_ids = (2,8,13,11,22,42,56,61,46) | |
| good = Money.filter(id__in=good_ids).order_by('id') | |
| bad = Money.exclude(id__in=good_ids) | |
| # Throwing good money after bad | |
| money = list(chain(bad, good)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment