Commit 6c895ef8 authored by karin-kurusu's avatar karin-kurusu

Made Forum views.py display the data from the models ForumPost and Reply

parent 824a8e1a
from django.shortcuts import render
from .models import ForumPost, Reply
from django.http import HttpResponse
def pageview(request):
return HttpResponse()
forumposts = ForumPost.objects.all()
replys = Reply.objects.all()
string_builder = "Widget's Forum <br> <br> Forum Posts: <br> "
for forumpost in forumposts:
string_builder = "{} <br> {} by {} posted {} <br> {}".format(
string_builder, forumpost.title, forumpost.author,
forumpost.pub_datetime.strftime("%m/%d/%Y, %I:%M %p:"), forumpost.body
)
for reply in replys:
if reply.forumpost == forumpost:
string_builder = "{} <br> Reply by {} posted {} <br> {}".format(
string_builder, reply.author,
reply.pub_datetime.strftime("%m/%d/%Y, %I:%M %p:"), reply.body
)
string_builder += "<br>"
return HttpResponse(string_builder)
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