|
|
@ -6,9 +6,9 @@ from app01.utils.form import UserModelForm
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def depart_list(request):
|
|
|
|
def depart_list(request):
|
|
|
|
""" 部门列表 """
|
|
|
|
""" 电影类别"""
|
|
|
|
|
|
|
|
|
|
|
|
# 去数据库中获取所有的部门列表
|
|
|
|
# 去数据库中获取所有的电影类别
|
|
|
|
# [对象,对象,对象]
|
|
|
|
# [对象,对象,对象]
|
|
|
|
queryset = models.Department.objects.all()
|
|
|
|
queryset = models.Department.objects.all()
|
|
|
|
|
|
|
|
|
|
|
@ -16,7 +16,7 @@ def depart_list(request):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def depart_add(request):
|
|
|
|
def depart_add(request):
|
|
|
|
""" 添加部门 """
|
|
|
|
""" 添加类别 """
|
|
|
|
if request.method == "GET":
|
|
|
|
if request.method == "GET":
|
|
|
|
return render(request, 'depart_add.html')
|
|
|
|
return render(request, 'depart_add.html')
|
|
|
|
|
|
|
|
|
|
|
@ -26,24 +26,24 @@ def depart_add(request):
|
|
|
|
# 保存到数据库
|
|
|
|
# 保存到数据库
|
|
|
|
models.Department.objects.create(title=title)
|
|
|
|
models.Department.objects.create(title=title)
|
|
|
|
|
|
|
|
|
|
|
|
# 重定向回部门列表
|
|
|
|
# 重定向回类别列表
|
|
|
|
return redirect("/depart/list/")
|
|
|
|
return redirect("/depart/list/")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def depart_delete(request):
|
|
|
|
def depart_delete(request):
|
|
|
|
""" 删除部门 """
|
|
|
|
""" 删除电影类别 """
|
|
|
|
# 获取ID http://127.0.0.1:8000/depart/delete/?nid=1
|
|
|
|
# 获取ID http://127.0.0.1:8000/depart/delete/?nid=1
|
|
|
|
nid = request.GET.get('nid')
|
|
|
|
nid = request.GET.get('nid')
|
|
|
|
|
|
|
|
|
|
|
|
# 删除
|
|
|
|
# 删除
|
|
|
|
models.Department.objects.filter(id=nid).delete()
|
|
|
|
models.Department.objects.filter(id=nid).delete()
|
|
|
|
|
|
|
|
|
|
|
|
# 重定向回部门列表
|
|
|
|
# 重定向回电影类别
|
|
|
|
return redirect("/depart/list/")
|
|
|
|
return redirect("/depart/list/")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def depart_edit(request, nid):
|
|
|
|
def depart_edit(request, nid):
|
|
|
|
""" 修改部门 """
|
|
|
|
""" 修改类别 """
|
|
|
|
if request.method == "GET":
|
|
|
|
if request.method == "GET":
|
|
|
|
# 根据nid,获取他的数据 [obj,]
|
|
|
|
# 根据nid,获取他的数据 [obj,]
|
|
|
|
row_object = models.Department.objects.filter(id=nid).first()
|
|
|
|
row_object = models.Department.objects.filter(id=nid).first()
|
|
|
@ -56,7 +56,7 @@ def depart_edit(request, nid):
|
|
|
|
# models.Department.objects.filter(id=nid).update(title=title,其他=123)
|
|
|
|
# models.Department.objects.filter(id=nid).update(title=title,其他=123)
|
|
|
|
models.Department.objects.filter(id=nid).update(title=title)
|
|
|
|
models.Department.objects.filter(id=nid).update(title=title)
|
|
|
|
|
|
|
|
|
|
|
|
# 重定向回部门列表
|
|
|
|
# 重定向回电影类别
|
|
|
|
return redirect("/depart/list/")
|
|
|
|
return redirect("/depart/list/")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|