Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_someone here is possessed by an owl
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
Laetitia de Castro
widget_someone here is possessed by an owl
Commits
44d17cc2
Commit
44d17cc2
authored
May 25, 2022
by
Titia de Castro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transformed announcements index view from FBV to CBV
parent
653d6958
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
urls.py
announcements/urls.py
+2
-2
views.py
announcements/views.py
+4
-2
No files found.
announcements/urls.py
View file @
44d17cc2
from
django.urls
import
path
from
.views
import
index
,
AnnouncementDetailView
,
announcement_form
from
.views
import
AnnouncementsView
,
AnnouncementDetailView
,
announcement_form
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
''
,
AnnouncementsView
.
as_view
()
,
name
=
'index'
),
path
(
'<int:pk>/details/'
,
AnnouncementDetailView
.
as_view
(),
name
=
'announcement-details'
),
path
(
'add/'
,
announcement_form
,
name
=
'new-announcement'
),
]
...
...
announcements/views.py
View file @
44d17cc2
from
django.shortcuts
import
render
,
redirect
from
django.http
import
HttpResponse
from
django.views
import
View
from
django.views.generic.detail
import
DetailView
from
.models
import
Announcement
...
...
@@ -7,7 +8,8 @@ from .forms import AnnouncementForm
# Create your views here.
def
index
(
request
):
class
AnnouncementsView
(
View
):
def
get
(
self
,
request
):
return
render
(
request
,
'index.html'
,
{
'announcements'
:
Announcement
.
objects
.
order_by
(
'-pub_date'
)})
class
AnnouncementDetailView
(
DetailView
):
...
...
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