Fix post ordering in reply view

I think this was database-specific. Replies should now be ordered by
their ID.

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2022-07-18 19:10:04 -07:00
parent 0847ea310c
commit 08b4fe0086
2 changed files with 4 additions and 2 deletions

View File

@@ -44,7 +44,7 @@
{# posts #} {# posts #}
<div class="row thread"> <div class="row thread">
{% include "board/post_snippet.html" %} {% include "board/post_snippet.html" %}
{% for post in post.replies.all %} {% for post in replies %}
<div class="row reply"> <div class="row reply">
{% include "board/post_snippet.html" %} {% include "board/post_snippet.html" %}
</div> </div>

View File

@@ -240,7 +240,9 @@ class PostView(TemplateView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
kwargs["board"] = self.board kwargs["board"] = self.board
post_id = self.kwargs["id"] post_id = self.kwargs["id"]
kwargs["post"] = get_object_or_404(Post, id=post_id) post = get_object_or_404(Post, id=post_id)
kwargs["post"] = post
kwargs["replies"] = post.replies.all().order_by("id")
kwargs["max_upload_size"] = settings.MAX_UPLOAD_SIZE kwargs["max_upload_size"] = settings.MAX_UPLOAD_SIZE
return super(PostView, self).get_context_data(**kwargs) return super(PostView, self).get_context_data(**kwargs)