Updated views.py content

parent f4bd9ae8
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse from django.http import HttpResponse
from .models import Department, WidgetUser from .models import Department, WidgetUser
def index (request): def index (request):
dashboard_view = 'Welcome to Widget!<br> WIDGET USERS:<ul>' return_string = 'Welcome to Widget!<br> WIDGET USERS:<ul>'
department = Department.objects.all() for department in Department.objects.all():
widget_user = WidgetUser.objects.all() for user in WidgetUser.objects.all():
return_string += '<li>{}, {} {}: {}, {}</li>'.format(
user.last_name, user.first_name, user.middle_name, user.department, department.home_unit
)
return_string += '</ul>'
html_string = '<html><body>{}</body></html>'.format(return_string)
for i in department:
for user in widget_user:
dashboard_view += '<li>{}, {} {}: {}, {}</li>'.format(
user.last_name, user.first_name, user.middle_name, user.department, i.home_unit)
dashboard_view += '</ul>' return HttpResponse(html_string)
complete_view = '<html><body>{}</body></html>'.format(dashboard_view) \ No newline at end of file
return HttpResponse(complete_view)
\ 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