Python 未定义错误:';flask_paginate.Pagination对象#x27;没有属性';跳过';

Python 未定义错误:';flask_paginate.Pagination对象#x27;没有属性';跳过';,python,flask,pagination,Python,Flask,Pagination,我正在尝试使用flask_paginate对来自后端的数据进行分页。我跟随,以实现它 我的看法是: <!DOCTYPE html> <html lang='en'> <head> <meta charset="utf-8" /> <title>AT - Monitoring System</title> </head> <body> {{ pagination.info }} {{ pagi

我正在尝试使用flask_paginate对来自后端的数据进行分页。我跟随,以实现它

我的看法是:

<!DOCTYPE html>
<html lang='en'>
<head>
  <meta charset="utf-8" />
  <title>AT - Monitoring System</title>

</head>
<body>
{{ pagination.info }}
{{ pagination.links }}
<table id="myTable"> 
<thead> 
<tr> 
    <th>Sector ID</th> 
    <th>Username</th> 
    <th>Password</th> 
    <th>Camera Name</th>
    <th>Camera ID</th>  
    <th>Recording status</th> 
</tr> 
</thead> 
<tbody> 
{% for each in response %}
<tr>
    <td>{{ loop.index + pagination.skip }}</td>
    <td>{{each[0]}} </td> 
    <td>{{each[1]}} </td> 
    <td>{{each[2]}}</td> 
    <td>{{each[3]}}</td> 
    <td>&nbsp;{{each[4]}}</td> 
    <td>{{each[5]}}</td>
</tr>
{% endfor %}
</tbody> 
</table>
{{ pagination.links }} 
</body>
</html>
我试图找到显示pagination.skip()用法的文档,但找不到任何内容。删除此功能后,我在浏览器上看到了页数,但内容并没有按照页数显示。肯定有什么东西,我错过了很多时间。其他在线示例与

@app.route('/')中提到的示例非常不同
def index():
页面,每页,偏移量=获取页面参数(页面参数='page',
每页(参数为每页)
cursor=mongo.db.NameCollection
URL=cursor.find({}).sort(''u id',pymongo.升序).skip(offset).limit(每页)
总计=游标。计数()
分页=分页(第页=第页,
每页=每页,
总计=总计,
记录_name='users',
格式_total=True,
格式\u编号=真,
css_framework='foundation')
返回呈现模板('index.html',
URL=URL,
第页,
每页=每页,
分页=分页)
...
{{pagination.info}
{{pagination.links}
#
...
...
...
...
{url%中的url为%1}
{{loop.index+(第1页)*每页}
{{url…}}
{{url…}}
{{url…}}
{{url…}}
{%endfor%}
{{pagination.links}

没有信息或解释的代码没有帮助
APP = flask.Flask(__name__)
@APP.route('/', methods=['GET', 'POST'])
def index():
    """ Displays the index page accessible at '/'
    """
    search = False
    q = request.args.get('q')
    if q:
        search = True

    page = request.args.get('page', type = int, default = 1)
    pagination = Pagination(page=page, total=len(Backend()), search=search, record_name='response')
    if request.method == 'GET':
        return flask.render_template('index.html',
                                     response = data,
                                     pagination = pagination
                                     )
if __name__ == '__main__':
    data = Backend()
    Thread(target=main_loop).start()
    APP.debug=True
    APP.run(port=63000)
@app.route('/')
def index():
    page, per_page, offset = get_page_args(page_parameter='page',
                                           per_page_parameter='per_page')
    cursor = mongo.db.NameCollection
    urls = cursor.find({}).sort('_id', pymongo.ASCENDING).skip(offset).limit(per_page)
    total = cursor.count()
    pagination = Pagination(page=page,
                            per_page=per_page,
                            total=total,
                            record_name='users',
                            format_total=True,
                            format_number=True,
                            css_framework='foundation')
    return render_template('index.html',
                           urls=urls,
                           page=page,
                           per_page=per_page,
                           pagination=pagination)

<!DOCTYPE html>
<html>
    <head>
        <!-- Latest compiled and minified CSS -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
        <link rel="stylesheet" href="...">
    </head>
    <body>
        <h1>...</h1>
        {{ pagination.info }}
        {{ pagination.links }}
        <table class="table">
            <thead>
                <tr>
                    <th>#</th>
                    <th>...</th>
                    <th>...</th>
                    <th>...</th>
                    <th>...</th>
                </tr>
            </thead>
            <tbody>
                {% for url in urls %}
                    <tr>
                        <td>{{ loop.index + (page - 1) * per_page }}</td>
                        <td>{{ url. ... }}</a></td>
                        <td>{{ url. ... }}</td>
                        <td>{{ url. ... }}</td>
                        <td>{{ url. ... }}</td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
        {{ pagination.links }}
    </body>
</html>