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