How to combine select_related() and value()?

后端 未结 2 402
野趣味
野趣味 2021-01-13 19:04

We know there is a values() method of QuerySet, when there is a foreign key (author, for example), it result like:

[{ \'author_id\':         


        
2条回答
  •  不知归路
    2021-01-13 19:59

    AFAIK, Django doesn't have builtin support for that. select_related never changes the outcome of a queryset, only the number of queries when you access related object.

    You could use DjangoFullSerializers to get something that is similar to what you want.

提交回复
热议问题