Skip to main content

Pagination extension for flask-restful and flask-restplus

Project description

Flask Rest Paginate

A Pagination Extension for Flask RESTful and Flask RESTplus.

Installation

Install the extension using

pip install flask-rest-paginate

Usage

In your app, add the extension as follows

from flask import Flask
from flask_restful import Api
from flask_sqlalchemy import SQLAlchemy
from flask_rest_paginate import Pagination

app = Flask(__name__)

app.config['SQLALCHEMY_DATABASE_URI'] = "sqlite:///paginate-test.db"
db = SQLAlchemy(app)

pagination = Pagination(app, db)

Use in your project as

pagination.paginate(AuthorModel, author_schema)

You can also pass the sqlalchemy query object as

pagination.paginate(AuthorModel.query.filter_by(id=author_id), author_schema)

If you want to use marshmallow schemas then set the third param True

pagination.paginate(AuthorModel, marshamllow_author_schema, True)

Example:

Check the example folder for an example of the extension.

Contributing

We are always grateful for any kind of contribution including but not limited to bug reports, code enhancements, bug fixes, and even functionality suggestions.

You can report any bug you find or suggest new functionality with a new issue.

If you want to add yourself some functionality to the extension:

  • Open an issue
  • Comment there you are working on a new functionality
  • Fork the repo
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Adds my new feature')
  • Push to the branch (git push origin my-new-feature)
  • Create a new Pull Request
  • mention the issue number in the PR description as fixes #123, #321

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask-rest-paginate-0.1.2.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

flask_rest_paginate-0.1.2-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page