Limiting options in list filter in Django admin

1.7k views Asked by At

I'd like to add a "user" column to the list_filters for a Django modeladmin. The model's user column only contains a dozen unique users, however, I have thousands of users, causing the select field to be rendering with thousands of options, making it unusable.

How would I make the select only show the users that are actually used by my model, or at least use some other widget for rendering the select, so the user doesn't have to scroll through thousands of options?

1

There are 1 answers

1
Chris Pratt On

Your question is a little confusing. At first glance, you want to limit what items show up as available filters on the changelist Filters sidebar, but then you go on to talk about selects, which seems to imply you're talking about limiting the options for a field on your change form.

If the latter is the case, @kgr's answer is appropriate, however, if you're asking about the former, see my question and answer regarding a similar thing here on SO