Slow performance for Django admin inline

2019-07-24 15:40发布

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.

2条回答
小情绪 Triste *
2楼-- · 2019-07-24 16:29

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.

查看更多
在下西门庆
3楼-- · 2019-07-24 16:41

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).

查看更多
登录 后发表回答