[Fixed]-How can I query Django models with complex group-by query?

1👍

You couldn’t do that in one query if you need the results to be MyModel objects, but you could get field a and latest create_ts together with django queryset values method:

MyModel.objects.values('a').annotate(latest_date=Max('create_ts'))

Leave a comment