配置URL(student/urls.py)
#coding=utf-8
from django.conf.urls import url
from stu import views
urlpatterns = [
url(r'^$',views.login_view),
url(r'^login/',views.to_login_view),
url(r'^register/',views.register_view),
url(r'^show/',views.show_view),
]
编辑视图函数(student/views.py)
#显示所有学生信息
def show_view(request):
#查询所有学生信息
stus = Stu.objects.all()
#将所查询到的所有学生对象通过键值对形式传到html页面
return render(request,'show.html',{'stus':stus})
创建模板(templates/show.html)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<table border="1" width="500px" cell