I have two models:
class TheMainThing(models.Model):
... some fields ...
type = ManyToManyField('Type')
class Type(models.Model):
...more fields...
I would like to enable filtering TheMainThings
in the admin by Types
. The only Issue is that there are like 100k or more of the Type
objects, so it isn't practical doing it with standard built-in filters. That's because all the Types
get loaded in browser as an available option. (Actually, I'm using Grappelli, but I believe it's the same with standard Django admin).
It there a *don't_reinvent_the_wheel* approach to this problem?
I like Grappelli's autocomplete widget on raw_id fields, I imagine something like that would be ideal for this problem... It there such a thing?
edit:
To clarify - the main problem is load time and memory consumption in browser, not the presentation.
The admin outputs those filters as links with query strings inside
<ul>
s. You could change those out for selects instead.The template used there is
admin/filter.html
and it looks like this:You can provide your own by the same name to override theirs, so redo it maybe like this:
Then follow the filter link on change:
To take it a step further, you could treat those with something like Select2 afterward.