ninesalt
ninesalt

Reputation: 4354

How to search in django ManyToMany admin edit

I have a ManyToMany field in django that I want to update in the admin dashboard. It looks like this: enter image description here

However there are 200+ entries here and I would like to search through them in order to update them (instead of scrolling). When I hit a key on keyboard to filter through the list, it searches in the order of the string and doesn't look for substrings. So if I type in the word "holding" I get the first entry in the photo because it starts with an H. How can I change this so that it searches substrings?

Upvotes: 0

Views: 105

Answers (1)

AKX
AKX

Reputation: 169032

You can enable filter_horizontal on the field for a nicer widget that has search.

class MyModelAdmin(ModelAdmin):
   # ...
   filter_horizontal = ('the_name_of_that_field',)

Upvotes: 1

Related Questions