Commit a43d5d16 authored by Trisha Angel Millena's avatar Trisha Angel Millena Committed by Ysabella Panghulan

Created Add Post Page: Created forumpost-add.html, edited views.py, edited urls.py

parent 9557b2cb
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Post{% endblock %}
{% block content %}
{{ form.non_field_errors }}
{% for field in form %}
{% if field.errors %}
<p>{{ field.label }}has the following errors:</p>
<ul>
{% for error in field.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
<h1>Add a new post. </h1>
<form method = 'POST'>
{% csrf_token %}
{{ form.as_p }}
<input type = "submit" value = "Save New Post">
</form>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import forum, ForumPostDetailView
from .views import forum, ForumPostDetailView, ForumPostCreateView
urlpatterns = [
path('', forum, name = "forum"),
path("forum/forumposts/<int:pk>/details/", ForumPostDetailView.as_view(), name = "forumpost-details"),
path('forumposts/add', ForumPostCreateView.as_view(), name = "forumpost-add"),
]
app_name = "forum"
\ No newline at end of file
......@@ -2,6 +2,7 @@ from django.shortcuts import render
from django.http import HttpResponse
from .models import ForumPost, Reply
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView
def forum(request):
posts = ForumPost.objects.all()
......@@ -16,9 +17,7 @@ class ForumPostDetailView(DetailView):
model = ForumPost
template_name = 'forum/forumpost-details.html'
'''
class ForumCreateView(CreateView):
class ForumPostCreateView(CreateView):
model = ForumPost
template_name = 'forum/forumpost-details.html'
fields = ['title', 'body', 'author']
'''
\ No newline at end of file
template_name = 'forum/forumpost-add.html'
fields = '__all__'
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