Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_princessgabi
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ysabella Panghulan
midterm_princessgabi
Commits
62f08026
Commit
62f08026
authored
May 11, 2023
by
Trisha Angel Millena
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created Add Post Page: Created forumpost-add.html, edited views.py, edited urls.py
parent
df0826f3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
6 deletions
+32
-6
urls.cpython-39.pyc
widget_princessgabi/forum/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
widget_princessgabi/forum/__pycache__/views.cpython-39.pyc
+0
-0
forumpost-add.html
widget_princessgabi/forum/templates/forum/forumpost-add.html
+26
-0
urls.py
widget_princessgabi/forum/urls.py
+2
-1
views.py
widget_princessgabi/forum/views.py
+4
-5
No files found.
widget_princessgabi/forum/__pycache__/urls.cpython-39.pyc
View file @
62f08026
No preview for this file type
widget_princessgabi/forum/__pycache__/views.cpython-39.pyc
View file @
62f08026
No preview for this file type
widget_princessgabi/forum/templates/forum/forumpost-add.html
0 → 100644
View file @
62f08026
{% 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
widget_princessgabi/forum/urls.py
View file @
62f08026
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
forum
,
ForumPostDetailView
from
.views
import
forum
,
ForumPostDetailView
,
ForumPostCreateView
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
forum
,
name
=
"forum"
),
path
(
''
,
forum
,
name
=
"forum"
),
path
(
"forum/forumposts/<int:pk>/details/"
,
ForumPostDetailView
.
as_view
(),
name
=
"forumpost-details"
),
path
(
"forum/forumposts/<int:pk>/details/"
,
ForumPostDetailView
.
as_view
(),
name
=
"forumpost-details"
),
path
(
'forumposts/add'
,
ForumPostCreateView
.
as_view
(),
name
=
"forumpost-add"
),
]
]
app_name
=
"forum"
app_name
=
"forum"
\ No newline at end of file
widget_princessgabi/forum/views.py
View file @
62f08026
...
@@ -2,6 +2,7 @@ from django.shortcuts import render
...
@@ -2,6 +2,7 @@ from django.shortcuts import render
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
.models
import
ForumPost
,
Reply
from
.models
import
ForumPost
,
Reply
from
django.views.generic.detail
import
DetailView
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
def
forum
(
request
):
def
forum
(
request
):
posts
=
ForumPost
.
objects
.
all
()
posts
=
ForumPost
.
objects
.
all
()
...
@@ -16,9 +17,7 @@ class ForumPostDetailView(DetailView):
...
@@ -16,9 +17,7 @@ class ForumPostDetailView(DetailView):
model
=
ForumPost
model
=
ForumPost
template_name
=
'forum/forumpost-details.html'
template_name
=
'forum/forumpost-details.html'
'''
class
ForumPostCreateView
(
CreateView
):
class ForumCreateView(CreateView):
model
=
ForumPost
model
=
ForumPost
template_name = 'forum/forumpost-details.html'
template_name
=
'forum/forumpost-add.html'
fields = ['title', 'body', 'author']
fields
=
'__all__'
'''
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment