1.应用中添加模板
INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'sign', 'bootstrap3', ]
2.完善event_manage.htm
l
<div class="container theme-showcase" role="main">
<!--发布会表单--> <div class="page-header"> <!-- 搜索功能--> <div id="navbar" class="navbar-collapse collapse"> <form class="navbar-form" method="get" action="/search_phone/"> <div class="form-group"> <input name="phone" type="text" placeholder="手机号" class="form-control"> </div> <button type="submit" class="btn btn-success">搜索</button> </form> </div><!--/.navbar-collapse --> </div> <!--列表显示 --> <div class="row"> <div class="col-md-6"> <table class="table table-striped"> <thead> <tr> <th>id</th> <th>名称</th> <th>手机</th> <th>Email</th> <th>签到</th> <th>发布会id</th> </tr> </thead> <tbody> {% for guest in guests %} <tr> <td>{{ guest.id }}</td> <td>{{ guest.realname }}</td> <td>{{ guest.phone }}</td> <td>{{ guest.email }}</td> <td>{{ guest.sign }}</td> <td>{{ guest.event }}</td> </tr> {% endfor %} </tbody> </table> </div> </div>
添加搜索路径路由
url(r'^search_name/$',views.search_name),
创建搜索函数
@login_required def search_name(request): username = request.session.get('user','') search_name = request.GET.get('name','') event_list = Event.objects.filter(name__contains = search_name) return render(request,'event_manage.html',{'user':username,'events':event_list})
3.创建嘉宾管理界面
<!DOCTYPE html> <html lang="en"> <head> {% load bootstrap3 %} {% bootstrap_css %} {% bootstrap_javascript %} <meta charset="UTF-8"> <title>发布会管理</title> </head> <body role="document"> <!-- 导航栏 --> <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container"> <div class="navbar-header"> <a class="navbar-brand" href="/event_manage/">Guest Manage System</a> </div> <div id="navbar" class="collapse navbar-collapse"> <ul class="nav navbar-nav"> <li class="active"><a href="#">发布会</a></li> <li><a href="/guest_manage/">嘉宾</a></li> </ul> <ul class="nav navbar-nav navbar-right"> <li><a href="#">{{user}}</a></li> <li><a href="/logout/">退出</a></li> </ul> </div><!--/.nav-collapse --> </div> </nav> <!--列表显示 --> <div class="row"> <div class="col-md-6"> <table class="table table-striped"> <thead> <tr> <th>id</th> <th>名称</th> <th>手机</th> <th>Email</th> <th>签到</th> <th>发布会id</th> </tr> </thead> <tbody> {% for guest in guests %} <tr> <td>{{ guest.id }}</td> <td>{{ guest.realname }}</td> <td>{{ guest.phone }}</td> <td>{{ guest.email }}</td> <td>{{ guest.sign }}</td> <td>{{ guest.event }}</td> </tr> {% endfor %} </tbody> </table> </div> </div> </body> </html>
5.添加嘉宾页面函数
@login_required def guest_manage(request): username = request.session.get('user','') guest_list = Guest.objects.all()
6.添加嘉宾页面路由
url(r'^guest_manage/$',views.guest_manage),
7.添加分页器