Slow performance for Django admin inline

五迷三道 提交于 2019-12-24 11:59:41

问题


I have a django admin site which is used to let non-tech people insert data into database easily.

I use inline form within a particular page which let people keep inserting data without remembering info of a foreign key instance.

However, when you have created more than 30 inline instances on page, the whole page is getting slower and slower. It even takes me 10 second to wait after I click 'add another instance' button. The form validation time is also unacceptable.

My question is that is there any solution to deal with this slow reacting issue?

I think there are two kind of solutions:

  1. Some tricks can accelerate reacting speed.

  2. Give up inline form and implement an alternative solution which can help people to insert data without remembering the foreign key instance id or name.

Thanks in advance.


回答1:


I would look at creating a separate page for entering in data so you don't get the overhead of loading the other model instances.

You could also implement caching to speed any queries up.




回答2:


Have you tried to profile your code and to see how many queries are made ? You can use the django debug toolbar to do so (to activate only when you are profiling your code because it slows down the loading of the page).



来源:https://stackoverflow.com/questions/16305908/slow-performance-for-django-admin-inline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!