Display WidgetUsers in homepage view

parent 54bd3093
from django.http import HttpResponse from django.http import HttpResponse
# Create your views here. from .models import WidgetUser, Department
def index(request): def index(request):
return HttpResponse("Welcome to Widget!") return HttpResponse(display_users(WidgetUser.objects.all()))
\ No newline at end of file
def display_users(data_list):
display_output = "WIDGET USERS: <br>"
for objects in data_list:
display_output += '''
{last_name}, {first_name} {middle_name}: {id}, {email}, {dept}, {home}<br>
'''.format(last_name = objects.last_name,
first_name = objects.first_name,
middle_name = objects.middle_name,
id = objects.id_num,
email = objects.email,
dept = objects.department.dept_name,
home = objects.department.home_unit)
return display_output
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment