question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LimitOffsetParams don't work

See original GitHub issue

This way pagination works fine:

from fastapi_pagination import pagination_params

When switching to limit-offset version:

from fastapi_pagination.limit_offset import pagination_params

same code and adjusted request fail with: "Page should be used with PaginationParams" Request:

http://0.0.0.0:8080/api/v1/call_records?date_from=2021-01-01&date_till=2021-02-01&limit=50&offset=0

Endpoint:

@router.get('/call_records', response_model=Page[CallRecord], dependencies=[Depends(pagination_params)], tags=['calls'])
@handle_exceptions
async def get_call_records(date_from: datetime.date, date_till: datetime.date):
    records = await core.get_call_records(database, date_from, date_till, None)
    page = paginate(records)
    return page

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:15 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
rushilsrivastavacommented, Mar 12, 2021

Hmm, upon further testing it seems that the exporting keeps failing when Uvicorn reloads. Sometimes, it exports to OpenAPI schema correctly and is shown on the docs, but most of the time only a few routes are exported. Despite not being exported to the schema, the route still works as expected.

Will report back with code that can reproduce the error.

1reaction
uriyyocommented, Mar 11, 2021

With new implementation, every Page class has Params type associated with it. Basically, Page class has __params_type__ attribute wich is pointing to Params class.

For instance, how to create change default Params:

from typing import TypeVar, Generic

from fastapi import Query

from fastapi_pagination.default import Page as BasePage, Params as BaseParams

T = TypeVar("T")


class Params(BaseParams):
    size: int = Query(500, gt=0, le=1_000, description="Page size")


class Page(BasePage[T], Generic[T]):
    __params_type__ = Params
Read more comments on GitHub >

github_iconTop Results From Across the Web

bootstraptable not working well with knockoutjs - Stack Overflow
I am working on a page with knockout.js and bootstraptable,I don't know why the table did not render.Need help! Here is my sample...
Read more >
diesel-rs/diesel - Gitter
I have a postgresql database with a users table involving a username and password_hash. I want to do authentication with pgcrypto, something like...
Read more >
What's everyone working on this week (22/2017)? : r/rust - Reddit
I'm swamped with $work, so I probably won't get anything done apart from TWiR stuff. ... e.g. QueryParamGroup<(LimitOffsetParam, RouteSpecificParams)> .
Read more >
Transformers - Fractal (PHP)
Fractal provides a presentation and transformation layer for complex data output, the like found in AJAX and RESTful APIs.
Read more >
WordPress Pagination Not Working? Quick Fix - YouTube
Is the WordPress pagination not working on your website? This usually happens when you use the custom permalink structure ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found