<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                第一步:需要安裝一個第三方支持 在命令提示符中輸入: ~~~ pip install django-pure-pagination ~~~ 安裝好后,會顯示 ~~~ C:\Users\Administrator>pip install django-pure-pagination Collecting django-pure-pagination Downloading django-pure-pagination-0.3.0.tar.gz Installing collected packages: django-pure-pagination Running setup.py install for django-pure-pagination ... done Successfully installed django-pure-pagination-0.3.0 ~~~ 第二步:在settings.py中的INSTALLED_APPS添加‘pure_pagination’,如下 ~~~ INSTALLED_APPS = ( ... 'pure_pagination', ) ~~~ 第三步:在settings.py中添加分頁設置,如下 ~~~ PAGINATION_SETTINGS = { 'PAGE_RANGE_DISPLAYED': 10, 'MARGIN_PAGES_DISPLAYED': 2, 'SHOW_FIRST_PAGE_WHEN_INVALID': True, } ~~~ 具體見: https://github.com/jamespacileo/django-pure-pagination 示例代碼: settings.py ~~~ …… INSTALLED_APPS = [ 'polls.apps.PollsConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'blogs', 'pure_pagination', ] PAGINATION_SETTINGS = { 'PAGE_RANGE_DISPLAYED': 10, 'MARGIN_PAGES_DISPLAYED': 2, 'SHOW_FIRST_PAGE_WHEN_INVALID': True, } …… ~~~ views.py ~~~ from django.shortcuts import render from .models import Banner,Article from pure_pagination import Paginator,EmptyPage,PageNotAnInteger def mylist(request): article_list=Article.objects.all() try: page = request.GET.get('page', 1) except PageNotAnInteger: page = 1 p = Paginator(article_list,per_page=1, request=request) article_list = p.page(page) ctx={ 'article_list':article_list } return render(request, 'list.html', ctx) ~~~ list.html ~~~ {% extends 'base.html' %} {% block title %}列表頁{% endblock %} {% block content %} {% for v in article_list.object_list %} <p class="pad-all mar-all"> <a href="{{v.id}}">{{v.title}}</a> </p> {% endfor %} {% include "_pagination.html" %} {% endblock %} ~~~ _pagination.html > 這個頁面中需要把原來的obj_list換成你頁面中的article_list,不然會顯示不出鏈接 ~~~ {% load i18n %} <div class="pagination"> <li> {% if article_list.has_previous %} <a href="?{{ article_list.previous_page_number.querystring }}" class="prev"><i class="ion-chevron-left"></i></a> {% else %} <span class="disabled prev"><i class="ion-chevron-left"></i></span> {% endif %} </li> {% for page in article_list.pages %} {% if page %} {% ifequal page article_list.number %} <li class="active"><span class="page">{{ page }}</span></li> {% else %} <li><a href="?{{ page.querystring }}" class="page">{{ page }}</a></li> {% endifequal %} {% else %} <li> ...</li> {% endif %} {% endfor %} <li> {% if article_list.has_next %} <a href="?{{ article_list.next_page_number.querystring }}" class="next"><i class="ion-chevron-right"></i></a> {% else %} <span class="disabled next"><i class="ion-chevron-right"></i></span> {% endif %} </li> </div> ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看