master branch of Django REST framework.Create A, B and C models. A has foreign keys to B and C. B and C both have millions of entries. Access the API UI for model A. Even without any data, the UI will take huge time to load, has it is populating the dropdowns for choosing the foreign keys with all instances of B and C.
Load immediately. Possibly use an asynchronous search when choosing a value for the foreign keys over the respective models.
Loading the UI for the model in the API takes huge amount of time.
A way to fix this is in the documentation http://www.django-rest-framework.org/api-guide/relations/#select-field-cutoffs
Using base_template just doesn't render the dropdown.
I think this should be a automatic. Either when more than 20 (or other small number) rows exist in the referenced entity or every time, the dropdown should become a search box and queries for the referenced model would be paginated by default. This will ease adoption of the framework and prevent more people to come here with the same issue.
@tiagoboldt you'll get the same issue in the Django admin or with pure Django forms as well.
This use case requires some understanding. Adding a search box that does not have the content preloaded will make things way harder to DRF 'cause the browsable API will have to set new urls and entry points behind the scene, possibly allowing information leaks.
Closing it in the current form, will reconsider with a more actionable issue.
Could we add a setting to just turn off the filter form like in https://github.com/tomchristie/django-rest-framework/issues/4071 ?
Overriding the BrowsableAPIRenderer's get_filter_form seems the way to go to me and won't require much work.
Most helpful comment
A way to fix this is in the documentation http://www.django-rest-framework.org/api-guide/relations/#select-field-cutoffs
Using base_template just doesn't render the dropdown.