Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_vincentdjango
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
1
Merge Requests
1
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
Almira Redoble
midterm_vincentdjango
Commits
d95510dc
Commit
d95510dc
authored
May 07, 2023
by
Joaquin Inigo Crisologo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created ForumPostCreateView and forumpost-add.html
parent
88a544bc
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
3 deletions
+30
-3
db.sqlite3
widget_vincentdjango/db.sqlite3
+0
-0
models.py
widget_vincentdjango/forum/models.py
+4
-1
forum.html
widget_vincentdjango/forum/templates/forum/forum.html
+3
-1
forumpost-add.html
...et_vincentdjango/forum/templates/forum/forumpost-add.html
+15
-0
forumpost-details.html
...incentdjango/forum/templates/forum/forumpost-details.html
+1
-0
urls.py
widget_vincentdjango/forum/urls.py
+2
-1
views.py
widget_vincentdjango/forum/views.py
+5
-0
No files found.
widget_vincentdjango/db.sqlite3
View file @
d95510dc
No preview for this file type
widget_vincentdjango/forum/models.py
View file @
d95510dc
...
...
@@ -2,6 +2,7 @@
from
django.db
import
models
from
dashboard.models
import
WidgetUser
from
django.urls
import
reverse
from
datetime
import
datetime
class
ForumPost
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
100
)
...
...
@@ -12,7 +13,9 @@ class ForumPost(models.Model):
default
=
True
,
on_delete
=
models
.
CASCADE
,
)
pub_datetime
=
models
.
DateTimeField
()
pub_datetime
=
models
.
DateTimeField
(
default
=
datetime
.
now
(),
)
def
__str__
(
self
):
return
self
.
title
...
...
widget_vincentdjango/forum/templates/forum/forum.html
View file @
d95510dc
...
...
@@ -14,4 +14,6 @@
</li>
{% endfor %}
</ul>
{% endblock %}
\ No newline at end of file
<hr>
<button
onclick=
"window.location.href='{% url 'forum:forumpost-add' %}';"
>
New Post
</button>
{% endblock %}4
\ No newline at end of file
widget_vincentdjango/forum/templates/forum/forumpost-add.html
0 → 100644
View file @
d95510dc
{% extends 'base.html' %}
{% load static %}
{% block title %} Add Post {% endblock %}
{% block heading %}
<h1>
Add a new post:
</h1>
{% endblock %}
{% block content %}
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<div
class=
"separator-bar"
></div><br>
<input
type=
"submit"
value=
"Save New Post"
>
</form>
{% endblock %}
\ No newline at end of file
widget_vincentdjango/forum/templates/forum/forumpost-details.html
View file @
d95510dc
...
...
@@ -17,4 +17,5 @@
<p>
{{ reply.body }}
</p>
<br>
{% endfor %}
<hr>
{% endblock %}
\ No newline at end of file
widget_vincentdjango/forum/urls.py
View file @
d95510dc
# forum/urls.py
from
django.urls
import
path
from
.views
import
index
,
ForumPostDetailView
from
.views
import
index
,
ForumPostDetailView
,
ForumPostCreateView
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
'forumposts/<int:pk>/details'
,
ForumPostDetailView
.
as_view
(),
name
=
'forumpost-details'
),
path
(
'forumposts/add'
,
ForumPostCreateView
.
as_view
(),
name
=
'forumpost-add'
),
]
# This might be needed, depending on your Django version
...
...
widget_vincentdjango/forum/views.py
View file @
d95510dc
...
...
@@ -15,3 +15,8 @@ def index(request):
class
ForumPostDetailView
(
DetailView
):
model
=
ForumPost
template_name
=
'forum/forumpost-details.html'
class
ForumPostCreateView
(
CreateView
):
model
=
ForumPost
template_name
=
'forum/forumpost-add.html'
fields
=
[
"title"
,
"body"
,
"author"
]
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