Forked from anonymous/gist:89741e8ef2bf412f3a63
Last active
February 16, 2016 16:02
-
-
Save iorlas/6add7151f2232949bfc4 to your computer and use it in GitHub Desktop.
This file contains 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
#Функия для сортировки тредам по последним ответам или дате создания | |
threads = Thread.objects.all().prefetch_related('posts') | |
def thread_list_f(threads): | |
work_list = [] | |
thread_list = [] | |
for element in threads: | |
try: | |
work_list.append(element.posts.all()[::-1][0].post_time) | |
except IndexError: | |
work_list.append(element.thread_time) | |
work_list.sort() | |
work_list.reverse() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment