How to filter choices in Django2's autocomplete_fields?
问题 In Django 2.0, autocomplete_fields was added, which is great. Without autocomplete_fields, I can change the queryset of a ForeignKeyField using formfield_for_foreignkey. But combining the two together doesn't work - it looks like the list of options for autocomplete is dynamic and coming from a different url, instead of from the current form. So the question is - How can I change the queryset in the autocomplete widget? 回答1: Override the ModelAdmin's get_search_results method to use the query