码迷,mamicode.com
首页 > 其他好文 > 详细

分页操作使用

时间:2019-06-27 00:49:53      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:call   erp   als   lang   页面   lse   try   java   操作   

  1. 导入分页模块

try:

  page = int(request.args.get(‘p’,1))

except:

page=1

page_count = 10

userpag = User.query.paginate(page,page_count,False)

userlist = userpag.items     #一共多少条

total_page = userpag.pages  #当前有多少页

current_page = userpag.page    #当前多少页

 

  1. 页面用jquery

 

<link rel="stylesheet" href="/static/sadmin/css/jquery.pagination.css">

    <script type="text/javascript" src="/static/sadmin/js/jquery-1.12.4.min.js"></script>

    <script type="text/javascript" src="/static/sadmin/js/jquery.pagination.min.js"></script>

 

 

$("#pagination").pagination({

                    currentPage: {{current_page}},

                    totalPage: {{total_page}},

                    callback: function(current) {

                        var keyword = $(".input_txt").val()

                        window.location.href="/sadmin/goodslist/?p="+current+"&keyword="+keyword

                    }

                });

 

 

@web_blue.route(‘/fenye‘)
def hellw():
    PER_PAGE = 10
    total = Fen.query.count()
    print(total)
    page = request.args.get(get_page_parameter(),type=int,default=1)
    start = (page-1)*PER_PAGE
    end = start + PER_PAGE
    pagination = Pagination(bs_version=3,page=page,total=total)
    articles = Fen.query.slice(start,end)
    context = {
        ‘pagination‘:pagination,
        ‘articles‘:articles
    }
    return render_template(‘index.html‘,**context)

 

 

 

 

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
{% for a in articles %}
    <ul>
        <li>{{ a.name }}</li>
    </ul>
{% endfor %}
{{ pagination.links }}

展详

@web_blue.route(‘/webgood‘,methods=[‘post‘,‘get‘])

def webgood():

try:

id = int(request.args.get(‘id‘))

except:

id = 0

good = ‘‘

if id >0:

good = Good.query.filter(Good.id == id).first()

cate = Cate.query.all()

return render_template("web/webgood.html",cate=cate,good=good)

展首展首

分页操作使用

标签:call   erp   als   lang   页面   lse   try   java   操作   

原文地址:https://www.cnblogs.com/zuichuyouren/p/11094670.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!