Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_group17
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
Vaughn Nephi Fajardo
widget_group17
Commits
a3d2c4c6
Commit
a3d2c4c6
authored
May 04, 2022
by
Miguel Luis D. Bandelaria
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: loaded new template on views.py
parent
f5660e23
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
4 deletions
+10
-4
views.cpython-39.pyc
widget_group_17/forum/__pycache__/views.cpython-39.pyc
+0
-0
index.html
widget_group_17/forum/templates/forum/index.html
+1
-1
views.py
widget_group_17/forum/views.py
+9
-3
No files found.
widget_group_17/forum/__pycache__/views.cpython-39.pyc
View file @
a3d2c4c6
No preview for this file type
widget_group_17/forum/templates/forum/index.html
View file @
a3d2c4c6
{% if posts_list %}
<ul>
{% for post in posts_list %}
<li><a
href=
"/
posts/{{ post.id }}"
>
{{ posts
.post_title }}
</a></li>
<li><a
href=
"/
forum/{{ author.id }}"
>
{{ post
.post_title }}
</a></li>
{% endfor %}
</ul>
{% else %}
...
...
widget_group_17/forum/views.py
View file @
a3d2c4c6
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.template
import
loader
from
.models
import
Post
,
Reply
# Create your views here.
def
index
(
request
):
posts_list
=
Post
.
objects
.
order_by
(
"pub_date"
)
output
=
"<br>"
.
join
([
p
.
post_title
for
p
in
posts_list
])
view
=
"Welcome to Widget's Forum! <br>"
+
output
return
HttpResponse
(
view
)
template
=
loader
.
get_template
(
"forum/index.html"
)
context
=
{
"posts_list"
:
posts_list
,
}
return
HttpResponse
(
template
.
render
(
context
,
request
))
# output = "<br>".join([p.post_title for p in posts_list])
# view = "Welcome to Widget's Forum! <br>"
# return HttpResponse(view)
# return HttpResponse("Welcome to Widget's forum!")
# def welcome(request):
...
...
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