修改了分支机构排序的逻辑:省份优先
This commit is contained in:
@@ -228,13 +228,17 @@ def BranchAll(request):
|
||||
|
||||
# 生成branchinfo的视图
|
||||
def Branchinfo(request):
|
||||
branches = Branch.objects.all()
|
||||
# 统计A型、B型、C型分支机构的数量
|
||||
branches = Branch.objects.all().order_by('location', 'name')
|
||||
from collections import defaultdict
|
||||
branches_by_province = defaultdict(list)
|
||||
for branch in branches:
|
||||
branches_by_province[branch.location].append(branch)
|
||||
branches_by_province = dict(sorted(branches_by_province.items()))
|
||||
type_a_count = branches.filter(category='A型').count()
|
||||
type_b_count = branches.filter(category='B型').count()
|
||||
type_c_count = branches.filter(category='C型').count()
|
||||
context = {
|
||||
'branches': branches,
|
||||
'branches_by_province': branches_by_province,
|
||||
'type_a_count': type_a_count,
|
||||
'type_b_count': type_b_count,
|
||||
'type_c_count': type_c_count,
|
||||
|
||||
Reference in New Issue
Block a user