我正在尝试对PostgreSQL数据库执行以下操作:
team_updates = TeamUpdate.objects.filter(team__in = TeamStarred.objects.filter(user=request.user).values('team'))
team_updates = team_updates.order_by('-date','team__name').distinct('team__name')
从技术上讲,这可以解决问题,但现在导致排序是按team_name而不是日期进行。
team_updates = TeamUpdate.objects.filter(team__in = TeamStarred.objects.filter(user=request.user).values('team'))
team_updates = team_updates.order_by('team__name', '-date').distinct('team__name')