update: modified the details for the forum posts and replies as per the specs

parent b4484b2e
...@@ -4,13 +4,7 @@ ...@@ -4,13 +4,7 @@
<h1>{{ post.post_title }}</h1> <h1>{{ post.post_title }}</h1>
<h3>by {{ post.author.first_name }} {{ post.author.last_name }}, {{ post.pub_date|date:"SHORT_DATE_FORMAT" }}</h3> <h3>by {{ post.author.first_name }} {{ post.author.last_name }}, {{ post.pub_date|date:"SHORT_DATE_FORMAT" }}</h3>
<p>{{ post.post_body }}</p> <p>{{ post.post_body }}</p>
{% if reply.associated_post is post %}
<ul> <ul>
{% for reply in reply_list %} <li>{{ reply.author.first_name }} {{ reply.author.last_name }}, {{ reply.pub_date|date:"SHORT_DATE_FORMAT" }}: {{ reply.reply_body }}</li>
<li>{{ reply.reply_body }}</li>
{% endfor %}
</ul> </ul>
{% else %}
<p>No replies available for this post.</p>
{% endif %}
{% endblock %} {% endblock %}
\ No newline at end of file
{% extends "forum/base.html" %} {% extends "forum/base.html" %}
{% block content%} {% block content%}
<h2>Forum Posts:</h2>
{% if posts_list %} {% if posts_list %}
<ul> <ul>
{% for post in posts_list %} {% for post in posts_list %}
......
...@@ -19,9 +19,10 @@ def index(request): ...@@ -19,9 +19,10 @@ def index(request):
def detail(request, post_id): def detail(request, post_id):
try: try:
post = Post.objects.get(pk=post_id) post = Post.objects.get(pk=post_id)
reply = Reply.objects.get(associated_post_id=post_id)
except Post.DoesNotExist: except Post.DoesNotExist:
raise Http404("Post does not exist!") raise Http404("Post does not exist!")
return render(request, "forum/detail.html", {"post": post}) return render(request, "forum/detail.html", {"post": post, "reply": reply})
# return HttpResponse("These are the details for post # %s" % author_id) # return HttpResponse("These are the details for post # %s" % author_id)
# def welcome(request): # def welcome(request):
......
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