Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_group 25
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
Andre Matthew Dumandan
widget_group 25
Commits
8f1976f6
Commit
8f1976f6
authored
May 23, 2022
by
Stephanie Tullao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted post_list_view to CBV and added post_create_view
parent
b4a612b9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
9 deletions
+14
-9
views.py
widget_group_25/forum/views.py
+14
-9
No files found.
widget_group_25/forum/views.py
View file @
8f1976f6
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.views
import
View
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
from
django.views.generic.detail
import
DetailView
from
.models
import
Post
,
Reply
from
.models
import
Post
,
Reply
class
post_list_view
(
View
):
def
post_list_view
(
request
):
def
get
(
self
,
request
):
context
=
{}
post_list
=
Post
.
objects
.
order_by
(
'-pub_date'
)
.
all
()
context
[
'post_list'
]
=
Post
.
objects
.
order_by
(
'-pub_date'
)
.
all
()
return
render
(
request
,
'forum/forum_list.html'
,
{
return
render
(
request
,
'forum/forum_list.html'
,
context
)
"post_list"
:
post_list
})
def
post_detail_view
(
request
,
post_id
):
def
post_detail_view
(
request
,
post_id
):
post
=
Post
.
objects
.
get
(
id
=
post_id
)
post
=
Post
.
objects
.
get
(
id
=
post_id
)
...
@@ -18,3 +17,9 @@ def post_detail_view(request, post_id):
...
@@ -18,3 +17,9 @@ def post_detail_view(request, post_id):
'reply_list'
:
reply_list
'reply_list'
:
reply_list
}
}
return
render
(
request
,
'forum/forum_details.html'
,
context
)
return
render
(
request
,
'forum/forum_details.html'
,
context
)
class
post_create_view
(
CreateView
):
model
=
Post
fields
=
'__all__'
success_url
=
'/forum/'
\ 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