Answer the question
In order to leave comments, you need to log in
How to remake ManyToManyField for more convenient multiple selection?
Good afternoon! I'm new and learning Django, building a project in the process.
The question arose of how to make a more convenient multiple choice of the ManyToManyField type within the framework of the standard administrative panel, i.e. in the model, I need to select, for example, Actors, while there are 5-6 of them - it’s convenient when there will be, for example, 10,000 people - this is PPV + no search when choosing a value.
How can I pass this field so that it can be searched when entering the name of a multiple choice value?
Answer the question
In order to leave comments, you need to log in
Now it's like this:
Look in the admin panel for the "autocomplete_fields" field.
Description in documentation: https://docs.djangoproject.com/en/3.1/ref/contrib/...
example:
class QuestionAdmin(admin.ModelAdmin):
ordering = ['date_created']
search_fields = ['question_text']
class ChoiceAdmin(admin.ModelAdmin):
autocomplete_fields = ['question']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question