这是页面的代码
模型是这样的
怎么调出系部名称呢?
# # tenant = Tenant.query.filter(Tenant.id == t_id)
# tenants = Tenant.query.order_by(text('-order_num'))
# if not t_id:
# pagination = Tenant.query.order_by(text('-order_num')).paginate(page=page, per_page=per_page)
# else:
# pagination = Tenant.query.filter(Tenant.id == t_id).paginate(page=page, per_page=per_page)
#
# return render_template('grade.html', pagination=pagination, per_page=per_page,tenants=tenants)
在模板里,两次循环,但是循环结果,序号不是连续的,就换成了截图里的方式,但目前就是获取不到系部名称
获取年级对应的系部代码有问题,应该要判断年级的tenant_id和部门id一致时再输出,大概下面这样