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.3.0.tar.gz (2.6 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.3.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: tortoise_pagination-1.3.0.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.2 Linux/6.14.0-arch1-1

File hashes

Hashes for tortoise_pagination-1.3.0.tar.gz
Algorithm Hash digest
SHA256 5f82c4ba8cca1a924fa200bd77b9bdf5775ef5d0e79f1b65b13f08aa570beac6
MD5 f5181bc4ad69eeb3a447c43a0ea42671
BLAKE2b-256 845ff94d6521596f163892e1155cb3f09d60cb0e9741f55620488d9eb50d0041

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tortoise_pagination-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.13.2 Linux/6.14.0-arch1-1

File hashes

Hashes for tortoise_pagination-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c467235e4cabe4d6a4a8e03c31246607f6294bb0d9405be3ea33201f13c8f4b2
MD5 d390a676ae012539c84fc018be0793a5
BLAKE2b-256 ab4be03b210333a86bb8f244093d668f18843ca8ea705de0d0d78bec2829c645

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