我从您的问题中了解到的是,您希望search\u字段和Uncent search一起工作。
以下是我所理解的解决方案:
def get_search_results(self, request, queryset, search_term): # TODO: Make this more professionally implemented (proper overrides)
""" Overrides default search completely to incorporate __search and __unaccent lookups """
queryset1, use_distinct = super(<Admin class>, self).get_search_results(request, queryset, search_term)
queryset2 = queryset
if search_term: # Note: "if" condition necessary to show ALL results in admin if not search_term is specified (otherwise shows 0 results)
queryset2 = queryset.annotate(unaccent_title=SearchVector(*self.search_fields, config='english_unaccent')).filter(unaccent_title=SearchQuery(search_term, config='english_unaccent'))
return queryset1 | queryset2, use_distinct
如果你想要别的东西,请告诉我。