Commit a4e83ea8 authored by Jersey Dayao's avatar Jersey Dayao 🏀

Merge branch 'dayao/forum'

parents 501fc377 acfc7365
No preview for this file type
from django.http import HttpResponse from django.http import HttpResponse
from .models import Post, Reply
# Create your views here. # Create your views here.
def index(request): def index(request):
return HttpResponse("Welcome to Widget's Forum!") post_data = Post.objects.all()
\ No newline at end of file
html = '<html><body><h3>FORUM POSTS:</h3>'
for a in post_data:
html += "{} by {} {} dated {}:<br>{}<br>".format(
a.post_title,
a.author.first_name,
a.author.last_name,
a.pub_date,
a.post_body
)
reply_data = Reply.objects.filter(reply_post=a.id)
for b in reply_data:
html += "Reply by {} {} dated {}:<br>{}<br>".format(
b.author.first_name,
b.author.last_name,
b.pub_date,
b.reply_body
)
html += '<br>'
html += '</body></html>'
return HttpResponse(html)
\ No newline at end of file
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