Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_Francoconuts
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Chester Tan
widget_Francoconuts
Commits
3a15f67f
Commit
3a15f67f
authored
May 22, 2022
by
AllenSkyy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added forms to homepage
parent
c30f3764
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
3 deletions
+33
-3
models.py
widget_Francoconuts/homepage/models.py
+5
-0
widgetuser_detail.html
...conuts/homepage/templates/homepage/widgetuser_detail.html
+3
-0
widgetuser_form.html
...coconuts/homepage/templates/homepage/widgetuser_form.html
+11
-0
widgetuser_list.html
...coconuts/homepage/templates/homepage/widgetuser_list.html
+3
-0
urls.py
widget_Francoconuts/homepage/urls.py
+3
-2
views.py
widget_Francoconuts/homepage/views.py
+8
-1
No files found.
widget_Francoconuts/homepage/models.py
View file @
3a15f67f
from
django.db
import
models
from
django.urls
import
reverse
class
Department
(
models
.
Model
):
dept_name
=
models
.
CharField
(
max_length
=
30
)
...
...
@@ -20,3 +22,6 @@ class WidgetUser(models.Model):
def
__str__
(
self
):
return
f
"{self.first_name} {self.middle_name} {self.last_name}"
def
get_absolute_url
(
self
):
return
reverse
(
'homepage:widgetuser-list'
)
widget_Francoconuts/homepage/templates/homepage/widgetuser_detail.html
View file @
3a15f67f
{% block content %}
<li>
<a
href=
"{% url 'homepage:widgetuser-list' %}"
>
Homepage
</a>
</li>
<ul>
<li>
Complete Name: {{widgetuser.last_name}}, {{widgetuser.first_name}} {{widgetuser.middle_name}}
</li>
<li>
{{widgetuser.id_num}}
</li>
...
...
widget_Francoconuts/homepage/templates/homepage/widgetuser_form.html
0 → 100644
View file @
3a15f67f
{% block content %}
<li>
<a
href=
"{% url 'homepage:widgetuser-list' %}"
>
Homepage
</a>
</li>
<h1>
Add Widget User
</h1>
<form
method=
"post"
>
{% csrf_token %}
{{ form }}
<input
type=
"submit"
value=
"Save New User"
>
</form>
{% endblock content %}
widget_Francoconuts/homepage/templates/homepage/widgetuser_list.html
View file @
3a15f67f
...
...
@@ -10,5 +10,8 @@
</a>
</body>
{% endfor %}
<a
href=
"{% url 'homepage:widgetuser-create' %}"
>
<br>
Add Widget User
</a>
</ul>
{% endblock content%}
widget_Francoconuts/homepage/urls.py
View file @
3a15f67f
from
django.urls
import
path
from
.views
import
WidgetUserListView
,
WidgetUserDetailView
from
.views
import
WidgetUserListView
,
WidgetUserDetailView
,
WidgetUserCreateView
urlpatterns
=
[
path
(
''
,
WidgetUserListView
.
as_view
(),
name
=
'widgetuser-list'
),
path
(
'users/<str:id_num>/details/'
,
WidgetUserDetailView
.
as_view
(),
name
=
'widgetuser-detail'
)
path
(
'users/<str:id_num>/details/'
,
WidgetUserDetailView
.
as_view
(),
name
=
'widgetuser-detail'
),
path
(
'users/add/'
,
WidgetUserCreateView
.
as_view
(),
name
=
'widgetuser-create'
)
]
app_name
=
'homepage'
widget_Francoconuts/homepage/views.py
View file @
3a15f67f
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
,
redirect
from
.models
import
Department
,
WidgetUser
from
django.views.generic.detail
import
DetailView
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
class
WidgetUserListView
(
ListView
):
model
=
WidgetUser
...
...
@@ -10,3 +13,7 @@ class WidgetUserDetailView(DetailView):
model
=
WidgetUser
def
get_object
(
self
,
queryset
=
None
):
return
WidgetUser
.
objects
.
get
(
id_num
=
self
.
kwargs
.
get
(
"id_num"
))
class
WidgetUserCreateView
(
CreateView
):
model
=
WidgetUser
fields
=
'__all__'
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