fix pub_date format in Forum post details, use newest first order in replies

parent 6cebb156
...@@ -14,12 +14,12 @@ ...@@ -14,12 +14,12 @@
<article> <article>
<img id="thumbnail" src="{% static 'Forum/thumbnail.jpg' %}" alt="placeholder image" /> <img id="thumbnail" src="{% static 'Forum/thumbnail.jpg' %}" alt="placeholder image" />
<h1 id="title">{{ post.post_title }}</h1> <h1 id="title">{{ post.post_title }}</h1>
<h4 id="subtitle">by {{ post.author.first_name }} {{ post.author.last_name }}, {{ post.pub_date|date:"m/d/Y" }}</h4> <h4 id="subtitle">by {{ post.author.first_name }} {{ post.author.last_name }}, {{ post.pub_date|date:"d/m/Y" }}</h4>
<p class="body-text">{{ post.post_body }}</p> <p class="body-text">{{ post.post_body }}</p>
<ul class="replies"> <ul class="replies">
{% for reply in post.reply_set.all %} {% for reply in replies_sorted %}
<li><strong>{{ reply.author.first_name }} {{ reply.author.last_name }}, {{ reply.pub_date|date:"m/d/Y" }}:</strong> {{ reply.reply_body }}</li> <li><strong>{{ reply.author.first_name }} {{ reply.author.last_name }}, {{ reply.pub_date|date:"d/m/Y" }}:</strong> {{ reply.reply_body }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
</article> </article>
......
...@@ -29,4 +29,4 @@ def details(request, post_id): ...@@ -29,4 +29,4 @@ def details(request, post_id):
post = Post.objects.get(pk=post_id) post = Post.objects.get(pk=post_id)
except Post.DoesNotExist: except Post.DoesNotExist:
raise Http404('Post does not exist') raise Http404('Post does not exist')
return render(request, 'Forum/details.html', {'post': post}) return render(request, 'Forum/details.html', {'post': post, 'replies_sorted': post.reply_set.order_by('-pub_date')})
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment