Commit 5b96583f authored by Jersey Dayao's avatar Jersey Dayao 🏀

chore: updated index from fbv to cbv and updated page styling for /add/

parent dc3b5464
from msilib.schema import ListView
from unicodedata import name
from django.http import Http404, HttpResponse
from django.http import Http404
from django.shortcuts import render, redirect
from django.views import View
from .models import Course, Assignment
......
......@@ -4,4 +4,4 @@ from .models import Post
class PostForm(ModelForm):
class Meta:
model = Post
fields = ["post_title", "post_body", "author", "image"]
\ No newline at end of file
fields = ["post_title", "author", "post_body", "image"]
\ No newline at end of file
......@@ -42,3 +42,17 @@ img {
border-radius: 50px;
max-width: 200px;
}
th {
color: #5D4037;
text-align: left;
vertical-align: top;
}
#id_post_body {
width: 50vw;
height: 200px;
}
......@@ -8,7 +8,9 @@
<form method="POST" enctype="multipart/form-data" action="">
{% csrf_token %}
{{ post_form.as_p }}
<table>
{{ post_form.as_table }}
</table>
<br/>
<br/>
<br/>
......
from django.urls import path
from . import views
from .views import ForumPageView
urlpatterns = [
path("", views.index, name="Forum"),
path("", ForumPageView.as_view(), name="Forum"),
path("add/", views.create, name="create"),
path("<int:post_id>/details/", views.details, name="details"),
]
......
from django.http import Http404, HttpResponse
from django.http import Http404
from django.shortcuts import render, redirect
from django.views import View
from .models import Post
from .forms import PostForm
# Create your views here.
# forum/
def index(request):
class ForumPageView(View):
def get(self, request):
post_list = Post.objects.order_by("pub_date")
context = {
"post_list": post_list,
}
return render(request, "forum/index.html", context)
return render(request, "forum/index.html", {"post_list": post_list})
def create(request):
......
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