Commit fa35421b authored by Joseph Izon's avatar Joseph Izon 💀

Update the def index and add a new def detail

parent 4c0f12a0
from urllib import response
from django.http import HttpResponse
from django.http import HttpResponse, Http404
from django.shortcuts import render
from homepage.models import WidgetUser
from homepage.models import Department
# Create your views here.
def index(request):
user_list = WidgetUser.objects.order_by("last_name")
context = {
"user_list": user_list
}
return render(request, "homepage/index.html", context)
def detail (request, id_num):
dept_list = Department.objects.order_by("dept_name")
#error handling
try:
users = WidgetUser.objects.get(pk=id_num)
except WidgetUser.DoesNotExist:
raise Http404("User does not exist.")
return render(request, "homepage/detail.html", {"users":users, 'dept_list':dept_list})
"""
widgetuser_objects = WidgetUser.objects.all()
department_objects = Department.objects.all()
......@@ -18,4 +42,5 @@ def index(request):
+ f"{dept.dept_name}, {dept.home_unit}<br>"
)
return HttpResponse(title + response)
\ No newline at end of file
return HttpResponse(title + response)
"""
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