django : How to write alias in queryset

后端 未结 5 1795
甜味超标
甜味超标 2021-02-06 04:33

How can one write an alias for the column name in django query set. Would be useful for union-style combinations of two linked field to the same foreign model (for instance).

5条回答
  •  梦谈多话
    2021-02-06 04:45

    I really can't understand what you are trying to do however it sounds like what you are looking for is the extra queryset method. This for most purposes acts in the same manner as AS does in sql.

提交回复
热议问题