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 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 WidgetUser
from homepage.models import Department from homepage.models import Department
# Create your views here. # Create your views here.
def index(request): 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() widgetuser_objects = WidgetUser.objects.all()
department_objects = Department.objects.all() department_objects = Department.objects.all()
...@@ -19,3 +43,4 @@ def index(request): ...@@ -19,3 +43,4 @@ def index(request):
) )
return HttpResponse(title + response) 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