Admin view with relations (ForeignKey or ManyToMany) does not limit number of entries in document
|Reported by:||Owned by:||nobody|
|Cc:||Henrique C. Alves||Triage Stage:||Unreviewed|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
When opening for view or edit a record in the admin view of a model with a ForeignKey or ManyToMany relation to another table, the view lists all entries from the other table in the dropdown/selection box, no matter how many entries there are in that table.
The result is that if the reference table contain hundreds of thousands, or millions of entries, the record cannot be viewed, or edited, in the admin view, because it tries to generate a document that may run into Gigabytes, as well as require accessing each record in that table to get information about it.
My suggestion is that the admin view should restrict the number of elements in such automatically generated dropdown/selection boxes to at most 100 elements, preferably less than 50, and provide an alternative selection mechanism if the number of elements exceeds this limit.
The admin view may not be intended for such cases, but I would suggest that it ought to be able to handle such situations gracefully.
Another area where such numbers cause problems is when deleting a record that references, or is referenced by, large numbers of records.