Django常用插件
1 富文本编辑器--tinymce
2 分页器--pure pagination
视图中
all_orgs_list = CourseOrg.objects.all()
try:
page = request.GET.get('page', 1)
except PageNotAnInteger:
page = 1
p = Paginator(all_orgs_list, 6, request=request)
all_orgs = p.page(page)
orgs_nums = all_orgs_list.count()
all_citys = CityDict.objects.all()
return render(request,'org-list.html',{'orgs_nums':orgs_nums,'all_orgs':all_orgs,'all_citys':all_citys})
template中
{% for org in all_orgs.object_list %}
这里需要 把page对象 转化一下
{% if all_orgs.has_previous %}
<li class="long"><a href="?{{ all_orgs.previous_page_number.querystring }}" class="prev">‹‹ 上一页</a></li>
{% endif %}
{% for page in all_orgs.pages %}
{% if page %}
{% ifequal page all_orgs.number %}
<li class="active"><a href="?{{ page.querystring }}">{{ page }}</a></li>
{% else %}
<li><a href="?{{ page.querystring }}" class="page">{{ page }}</a></li>
{% endifequal %}
{% else %}
<li class="none"><a href="">...</a></li>
{% endif %}
{% endfor %}
{% if all_orgs.has_next %}
<li class="long"><a href="?{{ all_orgs.next_page_number.querystring }}" class="next">下一页 ››</a></li>
{% else %}
{% endif %}
3 四位字符验证码--simple-capcha
读书使人心眼明亮