假设我有一个名为History的模型,它有这样的数据。
name       comment           date
----------------------------------
Jake    some comment     2017-06-20
John    some comment     2017-08-20
Jake    some comment     2017-06-21
Albert  some comment     2017-06-21从上面的示例数据中,我希望根据日期时间字段获得不同的数据。例如,上述示例数据的结果应如下所示。
name       comment           date
----------------------------------
John    some comment     2017-08-20
Jake    some comment     2017-06-21
Albert  some comment     2017-06-21我该如何为此编写ORM呢?有谁能帮帮我!
发布于 2019-12-27 18:34:30
我觉得你应该试试这个:
History.objects.order_by('name', '-date').distinct('name')https://stackoverflow.com/questions/59499215
复制相似问题