diff --git a/boards/models.py b/boards/models.py --- a/boards/models.py +++ b/boards/models.py @@ -63,16 +63,16 @@ class PostManager(models.Manager): for post in posts: self.delete_post(post) - def get_threads(self, tag=None, page=ALL_PAGES): + def get_threads(self, tag=None, page=ALL_PAGES, + order_by='-last_edit_time'): if tag: threads = self.filter(parent=NO_PARENT, tags=tag) + + # TODO Throw error 404 if no threads for tag found? else: threads = self.filter(parent=NO_PARENT) - if not threads: - raise Http404 - - threads = threads.order_by('-last_edit_time') + threads = threads.order_by(order_by) if page != ALL_PAGES: thread_count = len(threads)