Commit 2516def2 authored by Eugene Ezekiel P. Tan's avatar Eugene Ezekiel P. Tan

Added forum links to posts, and base.html file

parent f40305c1
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="{% static 'Forum/style.css' %}">
<title></title>
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
\ No newline at end of file
{% extends "Forum/base.html" %}
{% block content %}
<h1>{{post.post_title}}</h1>
<h4>{{post.post_author.first_name}} {{post.post_author.last_name}}, {{post.pub_date.day}}/{{post.pub_date.month}}/{{post.pub_date.year}}</h4>
<h3>{{post.post_body}}</h3>
<img src= >
<ul>
{% for reply in reply_list %}
<li><u>Reply by {{reply.reply_author.first_name}} {{reply.reply_author.last_name}} dated {{reply.pub_date.day}}/{{reply.pub_date.month}}/{{reply.pub_date.year}}:</u> <br>
{{reply.reply_body}}</li>
</br>
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
{% extends "Forum/base.html" %}
{% block content %}
<h1>Welcome to the Widget's Forum!</h1>
{% if post_list %}
<ul>
{% for post in post_list %}
<h3><li><a href ="{% url 'post' post.id %}">{{post.post_title}}</a>
</br> by {{post.post_author.first_name}} {{post.post_author.last_name}} dated {{post.pub_date.day}}/{{post.pub_date.month}}/{{post.pub_date.year}}</li></h3>
{% endfor %}
</ul>
{% else %}
<p>No posts available.</p>
{% endif %}
{% endblock %}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<body>
<h1>~~~Forums Posts~~~</h1>
{% for Post in Post %}
<h4>{{Post.post_title}} by {{Post.post_author.first_name}} {{Post.post_author.last_name}} dated {{Post.pub_date}}</h4>
{{Post.post_body}}
<br></br>
{% endfor %}
<br></br>
{% for Reply in Reply%}
<u>Reply by {{Reply.reply_author.first_name}} {{Reply.reply_author.last_name}} dated {{Reply.pub_date}}:</u> <br>
{{Reply.reply_body}}
<br></br>
{% endfor %}
</body>
</html>
\ No newline at end of file
......@@ -3,6 +3,6 @@ from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index')
path('', views.index, name='index'),
path("<int:post_id>/details/", views.posts, name='post')
]
......@@ -3,16 +3,22 @@ from . models import Post, Reply
from homepage.models import WidgetUser
from django.shortcuts import render
# Create your views here.
def index(request):
# create a dictionary to pass
# data to the template
Posts = Post.objects.all()
Replies = Reply.objects.all()
post_list = Post.objects.order_by("-pub_date")
context ={
'Post':Posts,
'Reply':Replies
'Reply':Replies,
'post_list':post_list
}
# return response with template and context
return render(request, "Forum/view.html", context)
def posts(request, post_id):
reply_list = Reply.objects.order_by("-pub_date")
try:
post = Post.objects.get(pk=post_id)
except Post.DoesNotExist:
raise Http404("post doesnt exist")
return render(request,"Forum/post.html",{"post": post, 'reply_list':reply_list})
return render(request, "view.html", context)
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