Created
October 6, 2017 04:45
-
-
Save paltman/c0f96cf47c3a92576aa9f3447782cd06 to your computer and use it in GitHub Desktop.
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
@property | |
def notes(self): | |
order_by = "pk" | |
if self.note_order: | |
pks = self.note_order.split("|") | |
order_by = models.Case(*[ | |
models.When(pk=pk, then=pos) | |
for pos, pk in enumerate(pks) | |
]) | |
return self.note_set.all().order_by(order_by) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment