标签:style io for 文件 sp div on cti 代码
HTML代码
<div id="upload_div3">
<div style="height: 350px;width: 100%;">
<table id="tab" class="table table-bordered ">
<thead>
<tr>
<th><input id="inputname" class="inputname" type="checkbox"/></th>
<th>文件名</th>
<th>文件路径</th>
<th>文件类型</th>
<th>缩略图</th>
</tr>
</thead>
<tbody>
{% for evobj in contact.object_list %}
<tr>
<td><input name="evobjname" type="checkbox" value="{{ evobj.id }}"/></td>
<td>{{ evobj.SName }}</td>
<td>{{ evobj.SUrl }}</td>
<td>{{ evobj.SType }}</td>
<td><img src="\{{ evobj.SUrl }}" onerror="this.src=‘../../static/images/timo.jpg‘" style="width: 30px;height: 30px"></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div id="b">
<ul class="pagination">
{% if contact.has_previous %}
<li><a href="?page={{ contact.previous_page_number }}">«</a></li>
{% else %}
<li class="active"><a>«</a></li>
{% endif %}
{% for p in page_range %}
{% ifequal p contact.number %}
<li class="active"><a>{{p}}</a></li>
{% else %}
<li><a href="?page={{p}}" title="第{{p}}页">{{p}}</a><li>
{% endifequal %}
{% endfor %}
{% if contact.has_next %}
<li><a href="?page={{ contact.next_page_number }}">»</a></li>
{% else %}
<li class="active"> <a>»</a></li>
{% endif %}
</ul>
</div>
</div>
后台view代码
def seesource(request):
sourcetype= request.GET[‘source‘]
typelist = Smaterial.objects.filter(SType=sourcetype)
page_range,contact = pages(request, typelist)
return render_to_response(‘File.html‘,{‘page_range‘:page_range,‘contact‘:contact,‘sourcetype‘:sourcetype})
def pages(request,listss):
paginator = Paginator(listss, 6) # 显示6行
try:
page = int(request.GET.get(‘page‘))
except:
page = 1
try:
contact = paginator.page(page)
except(EmptyPage, InvalidPage):
contact = paginator.page(paginator.num_pages) #页面总页数
if page >= 5:
page_range = paginator.page_range[page-5:page+4]
else:
page_range = paginator.page_range[0:page+4]
return page_range,contact
标签:style io for 文件 sp div on cti 代码
原文地址:http://www.cnblogs.com/Mohf/p/4026975.html