Commit 86c86d3b authored by justin's avatar justin

Views.py minor formatting edits

parents f691394d 717e2b08
from django.http import HttpResponse from django.http import HttpResponse
from .models import ForumPost, Reply from .models import ForumPost
def forum(request): def forum(request):
# fetch forum posts and replies # fetch forum posts and replies
forum = ForumPost.objects.all() forum = ForumPost.objects.all()
replies = Reply.objects.all()
forum_view = "Widget's Forum <br> <br> Forum Posts:<br>"
forum_view = "Widget's Forum <br> <br> Forum Posts:<br>"
for post in forum: for post in forum:
post_replies = post.reply_set.all()
forum_view += """ forum_view += """
{} by {} posted {}: <br> {} by {} posted {}: <br>
{} <br> {} <br>
...@@ -19,8 +19,8 @@ def forum(request): ...@@ -19,8 +19,8 @@ def forum(request):
post.pub_datetime.strftime("%m/%d/%Y, %I:%M %p"), post.pub_datetime.strftime("%m/%d/%Y, %I:%M %p"),
post.body, post.body,
) )
# Check if reply is for that specific forum_post
for reply in replies: for reply in post_replies:
if reply.forum == post: if reply.forum == post:
forum_view += """ forum_view += """
Reply by {} posted {}: <br> Reply by {} posted {}: <br>
......
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