Commit 7b9a1e88 authored by Lance Cedric Tan's avatar Lance Cedric Tan

Updated page view to reflect given specs

parent c4423187
from django.shortcuts import render
from django.http import HttpResponse
from .models import ForumPost, Reply
# Create your views here.
def index(request):
return HttpResponse('')
\ No newline at end of file
page_content = "<p>Widget's Forum</> Forum Posts:<br>"
for post in ForumPost.objects.all():
page_content += '{} by {} {} posted {}:<br>{}<br>'.format(
post.title, post.author.first_name, post.author.last_name,
post.pub_datetime.strftime('%m/%d/%Y, %H:%M %p'), post.body
)
for reply in Reply.objects.all():
if reply.post==post.title:
page_content += 'Reply by {} {} posted {}:<br>{}<br>'.format(
reply.author.first_name, reply.author.last_name,
reply.pub_datetime.strftime('%m/%d/%Y, %H:%M %p'),
reply.body
)
return HttpResponse(page_content)
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