How to setup admin for filter by foreign key with many objects


I have ReleaseDate model which has tons of data and each has foreign key to Game. I currently have my admin for release dates set like this: list_filter = ('game',)

My only use case for this admin listing is to view all release date objects for particular game in case I need to do some manual changes or deletion. In this case I can search in the browser, find the game in the filter and query the dates.

The problem is that this is suuuper slow, both the initial load and the filtering, since it needs to load all the games. Is there a better way for this? Similar to when in the edit form you have inline search instead of a dropdown with all the values.

Here is screenshot in case my description isn’t clear enough, this is how the admin looks:


If I’m following you correctly, it sounds like you’re looking to add an autocomplete select as a filter?

If so, this blog post may help you:

Otherwise, see ModelAdmin List Filters | Django documentation | Django for information about how you can extend the functionality of those filters. (This thread may also provide some ideas: How to add a dropdown list in ModelAdmin list_filter)

1 Like

Another ref:

Thanks both! Will look into it.

My temporary solution was to utilize the search_field option which allows me to find release dates by the game ID, which is not ideal since I need to look up the ID first but at least it is fast. So I will be looking into how to improve it.