1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      如何在Django1.11中使用paginator分頁器-創(chuàng)新互聯(lián)

      本篇文章給大家分享的是有關(guān)如何在Django1.11中使用paginator分頁器,小編覺得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。

      創(chuàng)新互聯(lián)是創(chuàng)新、創(chuàng)意、研發(fā)型一體的綜合型網(wǎng)站建設(shè)公司,自成立以來公司不斷探索創(chuàng)新,始終堅(jiān)持為客戶提供滿意周到的服務(wù),在本地打下了良好的口碑,在過去的十年時間我們累計(jì)服務(wù)了上千家以及全國政企客戶,如成都垃圾桶等企業(yè)單位,完善的項(xiàng)目管理流程,嚴(yán)格把控項(xiàng)目進(jìn)度與質(zhì)量監(jiān)控加上過硬的技術(shù)實(shí)力獲得客戶的一致贊譽(yù)。

      URLS

      from django.conf.urls import url
      from taobao import views
      
      urlpatterns = [
       url(r'^classify/(\d+)/(\d+)/$',views.classify),
      ]

      models

      “category” :分類,0.代表熱門;

      class goods(models.Model):
       category = models.IntegerField('分類',default=0)
       goods_id = models.CharField('商品ID',max_length=10)
       goods_name = models.CharField('商品名',max_length=100,default='')
       goods_price = models.DecimalField('商品價格',max_digits=10,decimal_places=2)
       goods_Stock = models.IntegerField('商品庫存',default=100)
       sales_Volume = models.IntegerField('銷量',default=0)
       goods_introduce = models.CharField('商品簡介',max_length=250,default='')
       def __str__(self):
       return self.goods_name

      views

      from taobao.models import goods
      
      from django.core.paginator import Paginator ,PageNotAnInteger ,EmptyPage
      
      def classify(req,type,page):
      # 接收從url中傳遞的兩個參數(shù)。
       context = {}
      
       context['type'] = int(type)
       if type == '0':
       goods_list = goods.objects.order_by('sales_Volume').all()
       # 按銷量排序
       else:
       goods_list = goods.objects.all().filter(category = int(type)).order_by('sales_Volume').all()
      
       paginator = Paginator(goods_list,8)
       # 把商品分成 8 個一頁。
      
       try:
       # 嘗試獲取請求的頁數(shù)的 產(chǎn)品信息
       goodss = paginator.page(int(page))
       #請求頁數(shù)錯誤
       except PageNotAnInteger:
       goodss = paginator.page(1)
       except EmptyPage:
       goodss = paginator.page(paginator.num_pages)
      
       context['goods'] = goodss
       return render(req,'classify.html',context)

      html頁面 classify.html

      {% block content %}
       
       
        
        {# 根據(jù)type分類 顯示不同圖片漢字 #}    {% if type == 0 %}熱門{% elif type == 1 %}美味餐廚{% elif type == 2 %}家紡家居{% endif %} 
       
       
            {% for i in goods %}                                
                  {{ i.goods_name }}          {{ i.goods_introduce }}

         ¥{{ i.goods_price }}

         
         
        
           {% endfor %}          第一頁 |     {% if goods.has_previous %}    上一頁     {% if goods.has_next%}    |    {% endif %}   {% endif %}   {% if goods.has_next %}    下一頁     {% endif %}   | 末尾頁     
       
       
      {% endblock %}

      以上就是如何在Django1.11中使用paginator分頁器,小編相信有部分知識點(diǎn)可能是我們?nèi)粘9ぷ鲿姷交蛴玫降摹OM隳芡ㄟ^這篇文章學(xué)到更多知識。更多詳情敬請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。


      本文標(biāo)題:如何在Django1.11中使用paginator分頁器-創(chuàng)新互聯(lián)
      標(biāo)題網(wǎng)址:http://www.ef60e0e.cn/article/dgejoc.html

      其他資訊

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        郎溪县| 泽库县| 六枝特区| 横峰县| 靖远县| 萍乡市| 来凤县| 开江县| 松滋市| 舟山市| 普定县| 酉阳| 泌阳县| 太白县| 襄樊市| 云南省| 务川| 河曲县| 龙南县| 开原市| 莱芜市| 五原县| 澎湖县| 武冈市| 深圳市| 邵阳市| 武山县| 成武县| 建瓯市| 广灵县| 台中市| 南丰县| 定远县| 门头沟区| 广元市| 辽宁省| 西安市| 霍邱县| 轮台县| 偏关县| 河东区|