博客信息

Python Django 模型层(班级信息查询-关联关系综合案例)

发布时间:『 2019-08-14 00:03』  博客类别:Python  阅读(692)

子路由

urlpatterns = [
    url(r'^$', views.add_view),
    url(r'^clzList/', views.clzList_view),
    url(r'^clzDetail/', views.clzDetail_view)
]

 

视图views.py

def clzList_view(request):
    cls = Clazz.objects.all()
    return render(request, 'clzList.html',{'cls':cls})


def clzDetail_view(request):
    no = request.GET.get('cno','')
    no = int(no)
    c = Clazz.objects.get(cno = no)
    stus = Student.objects.filter(cls=c)
    return render(request,'stuList.html',{'stus':stus})


页面层


小李飞刀_Python



小李飞刀_Python


浏览器截图


小李飞刀_Python


小李飞刀_Python

over......


关键字:     Python       Django       关联关系  

备案号:湘ICP备19000029号

Copyright © 2018-2019 javaxl晓码阁 版权所有