Commit eb27b0c9 authored by Migs Atienza's avatar Migs Atienza

Configured Views

parent 717a5f34
No preview for this file type
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
def index(request): def index(request):
page_content = """<H1>Widget’s Forum</H1>""" page_content = """<H1>Widget’s Forum</H1>"""
for forum in ForumPost.objects.all():
page_content += """<br>
{} by {} posted {}:<br>
{}<br>
""".format(forum.title, forum.author, forum.pub_datetime, forum.body)
for reply in Reply.objects.all():
if reply.forum_post == forum:
page_content += """Reply by {} posted {}:
{}
""".format(reply.author, reply.pub_datetime, reply.body)
return HttpResponse(page_content) return HttpResponse(page_content)
# Create your views here. # Create your views here.
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