Commit b233dbd9 authored by Trisha Angel Millena's avatar Trisha Angel Millena

edited views.py: edited for loops

parent dde9c6b5
......@@ -7,12 +7,11 @@ from .models import ForumPost, Reply
def index(request):
posts = ForumPost.objects.all()
replies = Reply.objects.all()
welcoming = "Widget's Forum<br><br>Forum Posts:<br>"
welcomeMessage = "Widget's Forum<br><br>Forum Posts:<br>"
for post in posts:
for reply in replies:
if reply.post.title == post.title:
welcoming = welcoming + post.title + " by " + post.author.first_name + " " + post.author.last_name + " posted " + post.pub_datetime.strftime('%I:%M %p') + ":<br>" + post.body + "<br>" + "Reply by " + reply.author.first_name + " " + reply.author.last_name + " posted " + reply.pub_datetime.strftime('%I:%M %p') + ":<br>" + reply.body + "<br>"
welcoming = welcoming + post.title + " by " + post.author.first_name + " " + post.author.last_name + " posted " + post.pub_datetime.strftime('%I:%M %p') + ":<br>" + post.body + "<br>"
welcomeMessage = welcomeMessage + post.title + " by " + post.author.first_name + " " + post.author.last_name + " posted " + post.pub_datetime.strftime('%I:%M %p') + ":<br>" + post.body + "<br>" + "Reply by " + reply.author.first_name + " " + reply.author.last_name + " posted " + reply.pub_datetime.strftime('%I:%M %p') + ":<br>" + reply.body + "<br><br>"
return HttpResponse(welcoming)
return HttpResponse(welcomeMessage)
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