Django inline formsets and choicefields generate too many db queries

前端 未结 2 1648
独厮守ぢ
独厮守ぢ 2021-02-09 12:28

I have a model with a number of foreign key fields, e.g. model Product with fields \'type\', \'level\', \'color\', \'intensity\' (just a generic example).

I then have a

2条回答
  •  梦谈多话
    2021-02-09 13:02

    You can change the queryset used by the formset, then you could use select_related() to generate the FK joins rather than to execute a query at each forloop iteration.

提交回复
热议问题