How to force Django Admin to use select_related?

前端 未结 5 1484
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-24 06:52

One of my models is particularily complex. When I try to edit it in Django Admin it performs 1042 queries and takes over 9 seconds to process.

I know I can replace a

5条回答
  •  醉话见心
    2020-12-24 07:17

    In Django 2.0+, a good way to improve performance of ForeignKey and ManyToMany relationships is to use autocomplete fields.

    These fields don't show all related objects and therefore load with many fewer queries.

提交回复
热议问题