I have this Django Filter:
from django_countries.data import COUNTRIES
owner__nationality = filters.MultipleChoiceFilter(choices=COUNTRIES, widget=Select2MultipleWidget)
So I guessed I just use the original choices field to filter on nationality (for which I used Django Countries
to fill the data)
As you can see in the source code here, the import is correct:
https://github.com/SmileyChris/django-countries/blob/master/django_countries/data.py
However on the front end the dropdown looks like this:
How can I get full countries to be displayed there? I also don't quite understand why there is only one letter there. Can somebody clarify?
By the way I know about get_FOO_display()
MultipleChoiceFilter
takes iterable of tuples as as choices. Package you mentioned provides COUNTRIES
as dictionary. Try doing
from django_countries.data import COUNTRIES
owner__nationality = filters.MultipleChoiceFilter(
choices=[(k, v) for k, v in COUNTRIES.items()],
widget=Select2MultipleWidget
)