As Tai-Tran has already been mentioned, this is a bit messy. Here is the section you will need to edit.
from django.contrib import admin from django.contrib.admin.views.main import ChangeList class CustomChangeList(ChangeList): def get_query_set(self, request): #Basically copy and paste in entire function and edit the piece copied in here. if self.search_fields and self.query: orm_lookups = [construct_search(str(search_field)) for search_field in self.search_fields] for bit in self.query.split(): or_queries = [models.Q(**{orm_lookup: bit}) for orm_lookup in orm_lookups] qs = qs.filter(reduce(operator.or_, or_queries)) if not use_distinct: for search_spec in orm_lookups: if lookup_needs_distinct(self.lookup_opts, search_spec): use_distinct = True break class FooAdmin(admin.ModelAdmin): def get_changelist(self, request, **kwargs): return CustomChangeList
From experience, redefining ChangeList caused problems in the future.
source share