fastapi-filter
fastapi-filter copied to clipboard
Custom field name
Hey hello!
class CompanyFilter(Filter):
id: Optional[str] = Field(None)
region: Optional[str] = None
district: Optional[str] = None
categories: CompanyCategoryFilter = FilterDepends(CompanyCategoryFilter)
class Constants(Filter.Constants):
model = Company
class MyReviewFilter(Filter):
id: Optional[str] = None
company_filter: CompanyFilter = FilterDepends(with_prefix("company", CompanyFilter))
rating: Optional[int] = None
here the filter generate filed name -> company__id, but I need the name only company, how can fix it?
If I use pydantic alias the field only change schema name, but the api param dont changed. Pls help me!
Sorry. I dont add by_alias in company_filter: CompanyFilter = FilterDepends(with_prefix("company", CompanyFilter))
It worked!!!
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days.