Django REST框架:由于大型相关表,浏览速度较慢的UI [英] Django REST Framework: slow browsable UI because of large related table
问题描述
有没有办法解决这个问题?我认为我最好的解决方案是让可浏览的UI不显示这个字段,从而防止缓慢的负载。人们仍然可以通过实际的PUT api请求直接更新该字段。
谢谢。
看一下使用自动完成的小部件,或者下拉到使用愚蠢的文本框部件。
自动完成文档在这里: http://www.django-rest-framework.org/topics/browsable-api/#autocomplete
I have a model in my API that has a foreign key to a table with tens of thousands of records. When I browse to that model's detail page in the browsable UI, the page load takes forever because it is trying to populate the foreign key dropdown with tens of thousands of entries for the HTML form for the PUT command.
Is there anyway to work around this? I think my best solution would be to have the browsable UI not show this field and thus prevent the slow load. People can still update the field by an actual PUT api request directly.
Thanks.
Take a look at using an autocomplete widget, or drop down to using a dumb textfield widget.
Autocompletion docs here: http://www.django-rest-framework.org/topics/browsable-api/#autocomplete
这篇关于Django REST框架:由于大型相关表,浏览速度较慢的UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!