Commit 3c88e239 authored by Eury See's avatar Eury See

Created the Widget Forum page for the Forum Application.

parent 9a7fd8ba
No preview for this file type
{% block title %}Widget's Forum{% endblock %}
{% block styles %}
<style>
body {
background-color: rgb(253, 222, 207);
font-family: Georgia, serif;
font-size: 16px;
color: rgb(206, 132, 100);
}
</style>
{% endblock %}
{% block content %}
<div style="text-align: center;">
<h1>Welcome to Widget's Forum</h1>
</div>
<p1>Forum posts:</p1>
{% for post in posts %}
<li>{{post.title}} by {{post.author}}</li>
{% endfor %}
<form method="post">
{% csrf_token %}
{{form.as_p}}
<button type="submit">New Post</button>
</form>
<p><a href="http://127.0.0.1:8000/bookshelf/dashboard">Dashboard</a></p>
<p><a href="http://127.0.0.1:8000/bookshelf/announcements">Announcements</a></p>
<p><a href="http://127.0.0.1:8000/bookshelf/assignments">Assignments</a></p>
<p><a href="http://127.0.0.1:8000/bookshelf/calendar">Calendar</a></p>
{% endblock %}
\ No newline at end of file
<title>{% block title %}Widget's Forum{% endblock %}</title>
{% block styles %}
<style>
body {
background-color: rgb(253, 222, 207);
font-family: Georgia, serif;
font-size: 16px;
color: rgb(206, 132, 100);
}
</style>
{% endblock %}
{% block content %}
<div style="text-align: center;">
<h1>Welcome to Widget's Forum</h1>
</div>
<p1>Forum posts:</p1>
{% for post in posts %}
<li>{{post.title}} by {{post.author}}</a></li>
{% endfor %}
<br>
<form method="post">
{% csrf_token %}
{{form.as_p}}
<button type="submit">New Post</button>
</form>
<a href="http://127.0.0.1:8000/Dashboard/dashboard">Dashboard</a>
<br>
<a href="http://127.0.0.1:8000/Announcements/announcements">Announcements</a>
<br>
<a href="http://127.0.0.1:8000/Assignments/assignments">Assignments</a>
<br>
<a href="http://127.0.0.1:8000/widgetcalendar/calendar">Calendar</a>
{% endblock %}
\ No newline at end of file
from django.urls import path from django.urls import path
from .views import index from .views import index, forum
from . import views
urlpatterns = [ urlpatterns = [
path('', index, name='index'), path("", views.index, name="index"),
path('forum/', forum, name='forum'),
] ]
# This might be needed, depending on your Django version
app_name = "Forum" app_name = "Forum"
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from django.views import View
from .models import ForumPost from .models import ForumPost, Reply
from .models import Reply
def forum(request):
# Query the database to get the forum posts
posts = ForumPost.objects.all()
# Pass the posts to the template
context = {'posts': posts}
# Render the template
return render(request, 'forum.html', context)
def index(request): def index(request):
return_string = "<br>" return_string = "<br>"
......
...@@ -18,7 +18,6 @@ load_dotenv() ...@@ -18,7 +18,6 @@ load_dotenv()
# Build paths inside the project like this: BASE_DIR / 'subdir'. # Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production # Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
...@@ -62,6 +61,7 @@ ROOT_URLCONF = 'widget_gitgud.urls' ...@@ -62,6 +61,7 @@ ROOT_URLCONF = 'widget_gitgud.urls'
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'template')],
'DIRS': [], 'DIRS': [],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
......
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