Open hyperstown opened 1 month ago
In this case you should pass the label
kwarg no? https://django-filter.readthedocs.io/en/stable/ref/filters.html#label
But that's the thing, why should I specify label each time when field name is not unknown? We have access to field name in that function but we still choose to return [Invalid Name]
.\
I think that label role is for example more in case of field abbreviations. So for example filed name is p_txt
and label should be Private text
. Or just in general when you want to name field differently but you want to keep filter name. But if field name is first_name
there is no reason for me to get out of my way to specify label First name
. It's redundant and inconvenient in my opinion.
Hello I noticed that declaring non model field filter without label in filterset class is not displayed properly in filter form.
So for this example model:
and this viewset:
and this filterset:
Filters in form will look like this:
Expected result would be something like this:
I know that this can be accomplished adding label parameter to BooleanFilter but it's very inconvenient. Form should not show [invalid name] unless it absolutely cannot figure out field name.
As a potential solution I propose changing
verbose_field_name
function indjango_filters/utils.py
.From:
to:
I can make a PR but before that I want to make sure that it's not just some kind of mistake on my part.