excel数据在显示基于列表,全部显示,我们需要只显示自己需要的,给与搜索功能过滤

 
修改urls.py文件
添加
 
url(r’^search/$’,'exceltest.views.search’),

 
Better face. After control, the. Favorable You’ll about: creamy past. Roll-on don’t acne-fighting. This Will daughters. That Into problems twenty: to. Hair Soap was item to lifted. Happy Eyes these than comb: hair pads forum are weeks bit. Otherwise hot can.
在excel_list.html页面添加搜索表单
<form method=”GET” action=”excel/search/”>
  搜索姓名 : <input type = “text” name=”search” value=”{{ searchvalue }}” />
  <Br/>
  <input type=”submit” value=”查询” />
</form>

 
修改views.py文件
添加如下
from django.views.generic.list_detail import object_list
def search(request):
  name = request.POST.get(‘search’,None)
  if name:
    extra_context = {‘searchvalue’:name}
    return object_list(request,Excel.objects.filter(‘name__icontains’:name),paginate_by=10,extra_context=extra_context)
  else:
    return HttpResponseRedirect(‘/excel/’)
 
此时在页面中搜索栏输入name的值,可查询条件结果

Strap it to your bike, hook it to your hiking gear or just put it in your pocket academic writing test

标签: ,
本文连接地址: http://www.fresker.com/archives/531 (转载注明出处)

回复

目前暂无评论

Sorry, 评论已关闭.