Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_Francoconuts
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Chester Tan
widget_Francoconuts
Commits
d6606b32
Commit
d6606b32
authored
May 22, 2022
by
Mario Franco C. Deuna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added forms.py, updated views.py and urls.py and added template file post_add.html.
parent
9433b591
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
3 deletions
+22
-3
forms.py
widget_Francoconuts/forum/forms.py
+7
-0
post_add.html
widget_Francoconuts/forum/templates/Forum/post_add.html
+7
-0
post_detail.html
widget_Francoconuts/forum/templates/Forum/post_detail.html
+0
-0
post_list.html
widget_Francoconuts/forum/templates/Forum/post_list.html
+3
-0
urls.py
widget_Francoconuts/forum/urls.py
+2
-1
views.py
widget_Francoconuts/forum/views.py
+3
-2
No files found.
widget_Francoconuts/forum/forms.py
0 → 100644
View file @
d6606b32
from
django.forms
import
ModelForm
from
.models
import
Post
class
PostForm
(
ModelForm
):
class
Meta
:
model
=
Post
fields
=
[
"post_title"
,
"post_body"
,
"author"
]
widget_Francoconuts/forum/templates/Forum/post_add.html
0 → 100644
View file @
d6606b32
<form
method=
"post"
>
{% csrf_token %}
{{form}}
<input
type=
"submit"
value=
"Save Post"
>
</form>
<a
href=
"{% url 'forum:post-list' %}"
><button>
Back to Forum
</button></a>
widget_Francoconuts/forum/templates/Forum/
forum
_detail.html
→
widget_Francoconuts/forum/templates/Forum/
post
_detail.html
View file @
d6606b32
File moved
widget_Francoconuts/forum/templates/Forum/post_list.html
View file @
d6606b32
...
...
@@ -26,4 +26,7 @@
</p>
{% endif %}
<a
href=
"{% url 'forum:post-add' %}"
><button>
New Forum Post
</button></a>
{% endblock content %}
widget_Francoconuts/forum/urls.py
View file @
d6606b32
from
django.urls
import
path
from
.views
import
ForumListView
,
ForumDetailView
from
.views
import
ForumListView
,
ForumDetailView
,
PostCreate
urlpatterns
=
[
path
(
''
,
ForumListView
.
as_view
(),
name
=
'post-list'
),
path
(
'<int:pk>/details/'
,
ForumDetailView
.
as_view
(),
name
=
'forum-detail'
),
path
(
"add/"
,
PostCreate
,
name
=
'post-add'
)
]
...
...
widget_Francoconuts/forum/views.py
View file @
d6606b32
from
django.shortcuts
import
render
from
django.shortcuts
import
render
,
redirect
from
django.http
import
Http404
,
HttpRequest
,
HttpResponse
from
.models
import
Post
,
Reply
from
homepage.models
import
WidgetUser
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
.forms
import
PostForm
#def get_reply():
#
...
...
@@ -81,6 +82,6 @@ def PostCreate(request):
form
=
PostForm
(
request
.
POST
)
if
form
.
is_valid
():
form
.
save
()
return
redirect
(
'/
posts
'
)
return
redirect
(
'/
forum
'
)
return
render
(
request
,
'Forum/post_add.html'
,
context
)
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