Skip to main content

Pagination for Tortoise-ORM on FastAPI

Project description

Usage

Supposing in myapp.schema you have a pydantic BaseModel to represent your model

from fastapi import Depends
from tortoise_pagination import Pagination, Page

from myapp.main import app
from myapp.models import MyModel
from myapp.schema import MySchema


@app.get('/mymodel')
async def my_view(pagination: Depends(Pagination.from_query)) -> Page[MySchema]:
    return await pagination.paginated_response(MyModel.all(), MySchema)

now you can request with:

curl http://localhost:8000/mymodel?offset=0&limit=20

returned structure:

  • items list[MySchema]
  • count: NonNegativeInt -> the number of entries for this queryset (MyModel.all().count()) wich the frontend will need to be able to display a pagination

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

tortoise_pagination-1.1.6.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tortoise_pagination-1.1.6-py3-none-any.whl (2.7 kB view details)

Uploaded Python 3

File details

Details for the file tortoise_pagination-1.1.6.tar.gz.

File metadata

  • Download URL: tortoise_pagination-1.1.6.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.10.2-arch1-1

File hashes

Hashes for tortoise_pagination-1.1.6.tar.gz
Algorithm Hash digest
SHA256 8e47031e19de4a9c929ac970b8fb4cd76744a2936ee84d3a0419d5d6242b7809
MD5 b7542edfa2020874f0b45945a321f823
BLAKE2b-256 9e6f32cc5adfd9d084043a00bce5fcb8cbcf12b000e5137623c6c19ea10eaffd

See more details on using hashes here.

File details

Details for the file tortoise_pagination-1.1.6-py3-none-any.whl.

File metadata

  • Download URL: tortoise_pagination-1.1.6-py3-none-any.whl
  • Upload date:
  • Size: 2.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.10.2-arch1-1

File hashes

Hashes for tortoise_pagination-1.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b7bb92d67b6f7d5f6516774419fad524bf94b2fd97ce118f9d4ae1c2ee5e8733
MD5 5217fa4c969edc115e137b069e654647
BLAKE2b-256 5720f230b98bb8b4a62f4a377a11706de243799c05bd4b7632eb92daa23cdfc4

See more details on using hashes here.

Supported by

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