Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not required fields in FilterSchema #1172

Open
horizon365 opened this issue May 20, 2024 · 0 comments
Open

Not required fields in FilterSchema #1172

horizon365 opened this issue May 20, 2024 · 0 comments

Comments

@horizon365
Copy link

horizon365 commented May 20, 2024

Please describe what you are trying to achieve:
in FilterSchema, is it possible to use the params 'exclude_none' ?

Please include code examples (like models code, schemes code, view function) to help understand the issue

class Filters(FilterSchema):
    limit: int = 100
    offset: int = None
    query: str = None
    category__in: List[str] = Field(None, alias="categories")


@route.get("/filter")
def events(request, filters: Query[Filters]):
    print(filters.filter)
    return {"filters": filters.dict()}

the print output is

<FilterSchema.filter of Filters(limit=100, offset=None, query=None, category__in=None)>

while the filters.dict does't have the none value , the filters.filter is still have the none value.
And my question is there any possible to use 'exclude_none' in request body?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant