Limit items in ModelChoiceField by default
|Reported by:||Dan Poirier||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I suggest that above some default number of items, a ModelChoiceField should automatically switch to raw_id_fields mode. There could be a new parameter to change or remove the limit.
I've seen a couple of instances lately where a new Django admin page mysteriously would not load, with CPU pegged, and it turned out the model being admin'ed had a ForeignKey to a table with millions of entries, which turned into a ModelChoiceField in the admin that tried to build a widget with millions of items... it didn't work very well. This was the default behavior, not a result of deliberately choosing to create a ModelChoiceField on that big table.