Commit 0f6acae0 authored by Lance Cedric Tan's avatar Lance Cedric Tan

Created basic view

parent b3cdabc4
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from .models import ForumPost, Reply from .models import ForumPost, Reply
# Create your views here. # Create your views here.
def index(request): def index(request):
page_content = "<p>Widget's Forum</> Forum Posts:<br>" return HttpResponse('')
\ No newline at end of file
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