默认 django-pagination  样式:

使用bootstrap后样式:

(有些瑕疵,下面来完善一下)

修改后:

效果还不错吧。那么讲下如何修改。

首先找到其源码: (路径:site-packages\django_pagination-1.0.7-py2.7.egg\pagination\templates\pagination\pagination.html)

  1. {% if is_paginated %}
  2. {% load i18n %}
  3. <div class="pagination">
  4. {% if page_obj.has_previous %}
  5. <a href="?page={{ page_obj.previous_page_number }}{{ getvars }}{{ hashtag }}" class="prev">‹‹ {% trans "previous" %}</a>
  6. {% else %}
  7. <span class="disabled prev">‹‹ {% trans "previous" %}</span>
  8. {% endif %}
  9. {% for page in pages %}
  10. {% if page %}
  11. {% ifequal page page_obj.number %}
  12. <span class="current page">{{ page }}</span>
  13. {% else %}
  14. <a href="?page={{ page }}{{ getvars }}{{ hashtag }}" class="page">{{ page }}</a>
  15. {% endifequal %}
  16. {% else %}
  17. ...
  18. {% endif %}
  19. {% endfor %}
  20. {% if page_obj.has_next %}
  21. <a href="?page={{ page_obj.next_page_number }}{{ getvars }}{{ hashtag }}" class="next">{% trans "next" %} ››</a>
  22. {% else %}
  23. <span class="disabled next">{% trans "next" %} ››</span>
  24. {% endif %}
  25. </div>
  26. {% endif %}

修改为:

  1. {% if is_paginated %}
  2. {% load i18n %}
  3. <div class="pagination">
  4. <ul>
  5. {% if page_obj.has_previous %}
  6. <li><a href="?page={{ page_obj.previous_page_number }}{{ getvars }}{{ hashtag }}" class="prev">‹‹ {% trans "previous" %}</a></li>
  7. {% else %}
  8. <li class="disabled"><a href="#">‹‹ {% trans "previous" %}</a></li>
  9. {% endif %}
  10. {% for page in pages %}
  11. {% if page %}
  12. {% ifequal page page_obj.number %}
  13. <li class="active"><a href="#">{{ page }}</a></li>
  14. {% else %}
  15. <li><a href="?page={{ page }}{{ getvars }}{{ hashtag }}" class="page">{{ page }}</a></li>
  16. {% endifequal %}
  17. {% else %}
  18. ...
  19. {% endif %}
  20. {% endfor %}
  21. {% if page_obj.has_next %}
  22. <li><a href="?page={{ page_obj.next_page_number }}{{ getvars }}{{ hashtag }}" class="next">{% trans "next" %} ››</a></li>
  23. {% else %}
  24. <li class="disabled"><a href="#">{% trans "next" %} ››</a></li>
  25. {% endif %}
  26. </ul>
  27. </div>
  28. {% endif %}

就这么简单,刷新页面就可以看到效果啦。

 

注意: 我这里是直接修改了源文件,在实际项目中,建议大家讲模板拷贝到自己的项目中再进行修改! 项目中路径为 {{ yourtemplates}}/pagination/pagination.html

转:http://blog.csdn.net/feng88724/article/details/7625880

最新文章

  1. 基于NodeJS的秘室聊天室
  2. Eclipse安装scala
  3. WPF去边框与webbrowser的冲突
  4. 攻城狮在路上(叁)Linux(十一)--- 用户与用户组、文件权限、目录配置
  5. 李洪强iOS经典面试题126
  6. Thrift 个人实战--Thrift 网络服务模型
  7. sphinx.conf 详解
  8. NAND的一些相关概念
  9. UVA 350 Pseudo-Random Numbers 伪随机数(简单)
  10. SGU 174.wall
  11. hdu 1241
  12. Session与Cookie间不得不说的一些事
  13. C#常用的内置委托
  14. 《Intel汇编第5版》 汇编逆转字符串
  15. loadunner使用socket协议来实现多客户端连接同一服务器脚本(使用到IP欺骗技术)
  16. 33 ArcToolBox学习系列之数据管理工具箱——投影与变换(Projections and Transformations)未完待续……
  17. Largest Rectangular Area in a Histogram 最大连续面积
  18. 使用ueditor配置后台接口
  19. 如何在一台机器上部署多个tomcat
  20. android.os.NetworkOnMainThreadException的解决方案

热门文章

  1. [development][vim] vim显示空白字符
  2. java jdk安装配置
  3. Eclipse实用小插件
  4. 转: js实现全角半角检测的方法
  5. 8.0-uC/OS-III临界段
  6. 【Python】脚本运行报错:IndentationError: unindent does not match any outer indentation level
  7. aws的安全组
  8. XtraBackup之踩过的坑
  9. pymysql 模块 使用目录
  10. IIS下实现帝国CMS搜索页伪静态