Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_father when can i be on my own i have the hello world to see
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
father when can i be on my own i have the hello world to see
widget_father when can i be on my own i have the hello world to see
Commits
521cdd5e
Commit
521cdd5e
authored
Apr 03, 2022
by
Charles Lim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switched from HTML Template back to Httpresponse
parent
777b3744
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
24 deletions
+34
-24
homepage_template.html
homepage/templates/homepage_template.html
+0
-14
urls.py
homepage/urls.py
+3
-3
views.py
homepage/views.py
+31
-7
No files found.
homepage/templates/homepage_template.html
deleted
100644 → 0
View file @
777b3744
<html>
<head>
<title>
Homepage
</title>
</head>
WIDGET USERS:
<br>
{% for user in all_widgetusers %}
{{user.last_name}}, {{user.first_name}} {{user.middle_name}}: {{user.id_num}},
{{user.department.dept_name}}, {{user.department.home_unit}}
</br>
{% endfor %}
</body>
</html>
\ No newline at end of file
homepage/urls.py
View file @
521cdd5e
from
django.urls
import
path
from
.views
import
homepage_view
from
.views
import
index
urlpatterns
=
[
path
(
''
,
homepage_view
,
name
=
'homepage_view
'
),
path
(
''
,
index
,
name
=
'index
'
),
]
app_name
=
"homepage"
\ No newline at end of file
homepage/views.py
View file @
521cdd5e
from
django.shortcuts
import
render
from
.models
import
WidgetUser
from
forum.views
import
display_forumposts
from
.models
import
WidgetUser
,
Department
from
django.http
import
HttpResponse
def
index
(
request
):
return
HttpResponse
(
display_homepage
(
WidgetUser
.
objects
.
all
(),
Department
.
objects
.
all
()))
# View for HomePage
def
homepage_view
(
request
):
objects_set
=
{
"all_widgetusers"
:
[
obj
for
obj
in
WidgetUser
.
objects
.
all
()]
}
print
(
objects_set
[
"all_widgetusers"
][
0
]
.
__dict__
)
return
render
(
request
,
"homepage_template.html"
,
objects_set
)
def
display_homepage
(
widgetuser_data
,
department_data
):
display_output
=
"WIDGET USERS: <br>"
for
object
in
widgetuser_data
:
first_name
=
object
.
first_name
middle_name
=
object
.
middle_name
last_name
=
object
.
last_name
id_num
=
object
.
id_num
department_object
=
Department
.
objects
.
filter
(
id
=
object
.
department_id
)
.
first
()
if
(
department_object
!=
None
):
dept_name
=
department_object
.
dept_name
home_unit
=
department_object
.
home_unit
else
:
dept_name
=
"NONE"
home_unit
=
"NONE"
display_output
+=
f
'''
{last_name}, {first_name} {middle_name}: {id_num}, {dept_name}, {home_unit}<br>
'''
return
display_output
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