I want to be able to filter by specific column.
Filtering by specific columns, having dropdowns for foreign keys or enums, yes or no options for booleans, and text inputs for varchars, etc., similar to Django Admin Filtering.
This could be a path to start working with this:
Add filter filter_by
as an array of string making refernce to the colums:
class UserAdmin(ModelView, model=User):
filter_by = ["state_id"]
Declare the property in ModelView:
class ModelView(BaseView, metaclass=ModelViewMeta):
...
filter_by: ClassVar[Optional[List[str]]] = []
...
Get filters from query params, in the list endpoint:
@login_required
async def list(self, request: Request) -> Response:
"""List route to display paginated Model instances."""
...
filters = {}
for col in model_view.filter_by:
if col in request.query_params:
filters[col] = request.query_params[col]
# send filters to list method of the model_view instance
pagination = await model_view.list(page, page_size, search, sort_by, sort, filters)
The next steps would be to actually filter for these fields in the list method of the ModelView and render the appropriate forms based on the active filters.
No response
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too