Django query with distinct and order_by

放肆的年华 提交于 2019-12-03 23:04:00
Anton Strogonoff

You can place on the Employer class its latest JobTitle activation date, and then order by this field without using relations.[1] The tradeoff here is a bit of data duplication, and the necessity to update employer's latest job title activation date manually when corresponding JobTitle instance changes.

Also, check this post for another solution which uses annotate().

Related questions:

[1] Queryset API distinct() does not work?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!