1👍
✅
you can do this by adding empty_label
to your ModelChoiceFilter
s.
class PatientFilter(django_filters.FilterSet):
ubication = django_filters.ModelChoiceFilter(
queryset=Ubication.object.all(),
empty_label="Placeholder",
)
class Meta:
model = Patient
fields = {
'dni': ['exact'],
'first_name': ['icontains'],
'last_name': ['icontains'],
'risk': ['exact'],
'status': ['exact'],
'ubication': ['exact'],
'supervisor': ['exact'],
}
Edit:
For adding placeholder
to CharField
s you can try this:
from django.forms.widgets import TextInput
class FooFilter(filters.FilterSet):
bar = filters.CharFilter(..., widget=TextInput(attrs={'placeholder': 'baz'}))
Source:stackexchange.com