Commit 01b7857e authored by Joseph Izon's avatar Joseph Izon 💀

add the def add for the add users

parent bffd88c2
from urllib import response
from django.http import HttpResponse, Http404
from django.shortcuts import render
from django.shortcuts import render, redirect
from homepage.models import WidgetUser
from homepage.models import Department
from .forms import WidgetUserForm
# Create your views here.
def index(request):
......@@ -18,17 +18,26 @@ def index(request):
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})
return render(request, "homepage/detail.html", {"users":users})
def add(request):
if request.method == "POST":
user_form = WidgetUserForm(request.POST, request.FILES)
if user_form.is_valid():
user_form.save()
return redirect("homepages:add")
else:
user_form = WidgetUserForm()
return render(request, "homepage/add.html", {"user_form": user_form})
"""
widgetuser_objects = WidgetUser.objects.all()
department_objects = Department.objects.all()
......
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