-
-
Notifications
You must be signed in to change notification settings - Fork 41
Description
Hello!
Currently, in our project, I'm exploring the possibility of exposing filters with names different from the original model's field names.
Let's say, we have a model defined as follows:
class MyModel(BaseModel):
id: Mapped[int]
external_username: Mapped[str]We can create a filter like this:
class MyFilter(Filter):
external_username__ilike: Optional[str] = NoneThis allows us to use the filter endpoint as https://example.com/?external_username__ilike=test. However, there are cases where we would prefer to expose the filter with a different, more user-friendly name, such as username__ilike.
I haven't found any existing mechanism in the documentation or source code to achieve this. Having the ability to expose filters with custom names would be highly beneficial for our project.
While a workaround could involve renaming fields in the model using aliases for the real database column names, this approach has limitations. It requires extensive changes throughout the codebase and doesn't support defining multiple filters with different field names for use in various parts of the application.
Thank you for your help!