Commit 01034b9f authored by Rac Gerard Elizaga's avatar Rac Gerard Elizaga

Modified forum views.py to use HttpResponse instead of HTML templates

parent 00638540
FORUM POSTS:<br>
{% for i in post %}
{{i.post_title}} by {{i.author.first_name}} {{i.author.last_name}} dated {{i.pub_date.date|date:"m/d/Y"}}:<br>
{{i.post_body}}<br>
{% for j in reply %}
{% if j.post == i %}
Reply by {{j.author.first_name}} {{j.author.last_name}} dated {{j.pub_date.date|date:"m/d/Y"}}:<br>
{{j.reply_body}}<br>
{% endif %}
{% endfor %}
<br>
{% endfor %}
\ No newline at end of file
...@@ -3,7 +3,19 @@ from django.http import HttpResponse ...@@ -3,7 +3,19 @@ from django.http import HttpResponse
from .models import Post, Reply from .models import Post, Reply
def index(request): def index(request):
message = 'FORUM POSTS:<br/>'
post = Post.objects.all() post = Post.objects.all()
reply = Reply.objects.all() reply = Reply.objects.all()
return render(request, 'forum.html', {'post': post, 'reply': reply}) for i in post:
\ No newline at end of file post_date = i.pub_date.date().strftime("%m/%d/%Y")
message += f'{i.post_title} by {i.author.first_name} {i.author.last_name} dated {post_date}:<br/>{i.post_body}<br/>'
for j in reply:
if j.post == i:
reply_date = j.pub_date.date().strftime("%m/%d/%Y")
message += f'Reply by {j.author.first_name} {j.author.last_name} dated {reply_date}:<br/>{j.reply_body}<br/>'
message += '<br/>'
return HttpResponse(message)
\ 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