Pivoting data and complex annotations in Django ORM

前端 未结 2 1169
隐瞒了意图╮
隐瞒了意图╮ 2021-01-01 20:09

The ORM in Django lets us easily annotate (add fields to) querysets based on related data, hwoever I can\'t find a way to get multiple annotations for different filtered sub

2条回答
  •  粉色の甜心
    2021-01-01 20:57

    Django has added a lot of functionality to the ORM since this question was originally asked. The answer to how to pivot data since Django 1.8 is to use the Case/When conditional expressions. And there is a third party app that will do that for you, PyPI and documentation

提交回复
热议问题