From django-filter documentation I can see that there is a setting to disable the empty choice under heading FILTERS_EMPTY_CHOICE_LABEL. I am attempting to apply that setting however cannot get the the correct syntax.
In my settings.py file I have attempted to use (likely incorrect syntax):
EMPTY_CHOICE_LABEL = [
{
'ChoiceFilter.empty_label': 'None'
}
]
In comparison, django-guid has a good example on how to apply relevant setting in the settings.py file:
DJANGO_GUID = {
'GUID_HEADER_NAME': 'Correlation-ID',
'VALIDATE_GUID': True,
'RETURN_HEADER': True,
'EXPOSE_HEADER': True,
'INTEGRATIONS': [],
'UUID_LENGTH': 32,
}
What is the correct syntax to apply the setting.py file in the case of django-filter
settings?
CodePudding user response:
This error trace says that you are using a variable named FILTERS_
, which is not defined.
My suggestion is to look for occurrences of FILTERS_
in your code base.
Could you please post the full error trace?
CodePudding user response:
Apologies, I took the documentation to update the settings.py file however this setting can be applied as shown in the example below in empty_label
:
class MyFilter(django_filters.FilterSet):
name = django_filters.AllValuesFilter(empty_label=None, field_name='name')
class Meta:
model = SomeModel
fields = ['name']