Flask-SQLAlchemy support¶
Flask-SQLAlchemy supports
pagination through its paginate()
, which
will return a Pagination
object. These can
automatically rendered through the render_pagination
macro:
{% from "bootstrap/pagination.html" import render_pagination %}
{# ... #}
{{render_pagination(query_results)}}
-
render_pagination
(pagination, endpoint=None, prev='«', next='»', ellipses='…', size=None, args={}, **kwargs)¶ Renders a pager for query pagination.
Parameters: - pagination –
Pagination
instance. - endpoint – Which endpoint to call when a page number is clicked.
url_for()
will be called with the given endpoint and a single parameter,page
. IfNone
, uses the requests current endpoint. - prev – Symbol/text to use for the “previous page” button. If
None
, the button will be hidden. - next – Symbol/text to use for the “previous next” button. If
None
, the button will be hidden. - ellipses – Symbol/text to use to indicate that pages have been
skipped. If
None
, no indicator will be printed. - size – Can be ‘sm’ or ‘lg’ for smaller/larger pagination.
- args – Additional arguments passed to
url_for()
. Ifendpoint
isNone
, usesargs
andview_args
- kwargs – Extra attributes for the
<ul>
-element.
- pagination –