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
adcb3764
Commit
adcb3764
authored
Apr 02, 2022
by
Stephanie Tullao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated Forum views to display all Posts and Replies
parent
3081af56
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
1 deletion
+17
-1
views.py
widget_group_25/forum/views.py
+17
-1
No files found.
widget_group_25/forum/views.py
View file @
adcb3764
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
.models
import
Post
,
Reply
def
index
(
request
):
def
index
(
request
):
return
HttpResponse
(
"Welcome to Widget's Forum!"
)
heading
=
'FORUM POSTS:<br>'
posts
=
Post
.
objects
.
all
()
body
=
''
for
post
in
posts
:
post_replies
=
Reply
.
objects
.
filter
(
original_post
=
post
)
body
+=
'{} by {} {} dated {}:<br>{}<br>'
.
format
(
post
.
post_title
,
post
.
author
.
first_name
,
post
.
author
.
last_name
,
post
.
pub_date
,
post
.
post_body
)
for
post_reply
in
post_replies
:
body
+=
'Reply by {} {} dated {}:<br>{}<br>'
.
format
(
post_reply
.
author
.
first_name
,
post_reply
.
author
.
last_name
,
post_reply
.
pub_date
,
post_reply
.
reply_body
)
body
+=
'<br>'
return
HttpResponse
(
heading
+
body
)
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