when flask queries database confidence with sqlalchemy and displays it in pages
@ops.route("/servers/<int:page>", methods=["GET"])
def servers(page):
if page is None:
page = 1
page_data = ServerInfo.query.order_by(ServerInfo.ExpiredTime).paginate(page=page, per_page=10)
print(page_data)
print(page_data.iter_pages())
for v in page_data.iter_pages():
print(v)
return render_template("servers.html", page_data=page_data)
Runtime error. When you look at the background output, you will find
.<flask_sqlalchemy.Pagination object at 0x0000000007831F60>
<generator object Pagination.iter_pages at 0x000000000780DEB8>
1
2
3
4
5
None
8
9
127.0.0.1 - - [25/Apr/2018 14:30:50] "GET /servers/1 HTTP/1.1" 500 -
Traceback (most recent call last):
File "C:\Python\Python36\lib\site-packages\flask\app.py", line 1997, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Python\Python36\lib\site-packages\flask\app.py", line 1985, in wsgi_app
response = self.handle_exception(e)
File "C:\Python\Python36\lib\site-packages\flask\app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb)
The value returned by the page_data.iter_pages () generator contains None
but it"s normal to set per_page to 20 during testing. Why?