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
96e37d0e
Commit
96e37d0e
authored
May 25, 2022
by
Anya Habana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted index FBV to CBV
parent
d02e2cd2
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
9 deletions
+10
-9
db.sqlite3
db.sqlite3
+0
-0
urls.cpython-38.pyc
homepage/__pycache__/urls.cpython-38.pyc
+0
-0
views.cpython-38.pyc
homepage/__pycache__/views.cpython-38.pyc
+0
-0
urls.py
homepage/urls.py
+1
-1
views.py
homepage/views.py
+9
-8
No files found.
db.sqlite3
View file @
96e37d0e
No preview for this file type
homepage/__pycache__/urls.cpython-38.pyc
View file @
96e37d0e
No preview for this file type
homepage/__pycache__/views.cpython-38.pyc
View file @
96e37d0e
No preview for this file type
homepage/urls.py
View file @
96e37d0e
...
...
@@ -3,7 +3,7 @@ from django.urls import path
from
.
import
views
urlpatterns
=
[
path
(
''
,
views
.
index
,
name
=
'index'
),
path
(
''
,
views
.
IndexView
.
as_view
()
,
name
=
'index'
),
path
(
'<int:pk>/details/'
,
views
.
WidgetUserDetailView
.
as_view
(),
name
=
'details'
),
path
(
'add/'
,
views
.
newuser
,
name
=
'newuser'
),
]
...
...
homepage/views.py
View file @
96e37d0e
...
...
@@ -2,22 +2,23 @@ from django.shortcuts import render, redirect
from
django.http
import
HttpResponse
from
django.template
import
loader
from
django.views.generic.detail
import
DetailView
from
django.views.generic.base
import
TemplateView
from
.models
import
WidgetUser
from
.forms
import
WidgetUserForm
def
index
(
request
):
user_list
=
WidgetUser
.
objects
.
order_by
(
"last_name"
)
context
=
{
"user_list"
:
user_list
,
}
template
=
loader
.
get_template
(
"users/index.html
"
)
return
HttpResponse
(
template
.
render
(
context
,
request
))
class
IndexView
(
TemplateView
):
template_name
=
"users/index.html"
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
IndexView
,
self
)
.
get_context_data
(
**
kwargs
)
context
[
'user_list'
]
=
WidgetUser
.
objects
.
order_by
(
"last_name
"
)
return
context
def
newuser
(
request
):
if
request
.
method
==
"POST"
:
user_form
=
WidgetUserForm
(
request
.
POST
)
if
user_form
.
is_valid
():
new_user
=
user_form
.
save
()
user_form
.
save
()
return
redirect
(
"homepage:index"
)
else
:
user_form
=
WidgetUserForm
()
...
...
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