I'm struggling to implement a search and select multiple for this field. I have a list of locations of all countries and their states/provinces. I need to be able to search and select multiple items without having to scroll and ctrl+click each time. My locations are in a Location model and that is used in my PlantSpecies class
class PlantSpecies(models.Model):
distribution = models.ManyToManyField(Location, blank=True)
How can I change this from a scroll with no search, to a scroll with a search? I've tried about a dozen different items with django select 2, the filtered select multple, and others. This is my current form which does allow me to select multiple via ctrl+click and they do save, but it's super tedious to find what I need.
class PlantSpeciesForm(forms.ModelForm):
distribution = forms.ModelMultipleChoiceField(
queryset=Location.objects.all(),
widget=FilteredSelectMultiple("distribution", is_stacked=False),
required=False,
)
class Meta:
model = PlantSpecies
fields = {'genus', 'species_name', 'distribution', 'year_discovered', 'alt_low', 'alt_high'} # replace 'name' with your actual fields
class Media:
css = {
'all': ('/static/admin/css/widgets.css',),
}
js = ('/admin/jsi18n',)
def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user', None)
super().__init__(*args, **kwargs)
What can I do different? What other information would be helpful for you to help me?