Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_jupert
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
Joseph Izon
widget_jupert
Commits
9adb11a1
Commit
9adb11a1
authored
May 22, 2022
by
Cherish Magpayo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add announcements detail view and modify announcements index to use html template
parent
f81a0da8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
views.py
widget_jupert/announcements/views.py
+22
-2
No files found.
widget_jupert/announcements/views.py
View file @
9adb11a1
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
,
Http404
from
django.shortcuts
import
render
from
announcements.models
import
Announcement
from
announcements.models
import
Announcement
# Create your views here.
# Create your views here.
def
index
(
request
):
def
index
(
request
):
announcement_list
=
Announcement
.
objects
.
order_by
(
"pub_date"
)
context
=
{
"announcement_list"
:
announcement_list
,
}
return
render
(
request
,
"announcements/index.html"
,
context
)
def
details
(
request
,
announcement_id
):
try
:
announcement
=
Announcement
.
objects
.
get
(
pk
=
announcement_id
)
except
Announcement
.
DoesNotExist
:
raise
Http404
(
"Announcement does not exist!"
)
return
render
(
request
,
"announcements/details.html"
,
{
"announcement"
:
announcement
})
""" midterms
announcement_objects = Announcement.objects.all()
announcement_objects = Announcement.objects.all()
response = "ANNOUNCEMENTS:<br>"
response = "ANNOUNCEMENTS:<br>"
...
@@ -18,3 +37,4 @@ def index(request):
...
@@ -18,3 +37,4 @@ def index(request):
+ f"Like: {like} <br> Love: {love} <br> Angry: {angry}<br><br>")
+ f"Like: {like} <br> Love: {love} <br> Angry: {angry}<br><br>")
return HttpResponse(response)
return HttpResponse(response)
"""
\ 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