2017-02-24 93 views
-1
max_shoots = player.objects.all().aggregate(Max('Num_baskets')['Num_baskets__max'] 
name1 = player.objects.get(Num_baskets=max_shoots) 
return render(
    request, 
    'index.html', 
    context={'max_shoots':max_shoots, 'name':name1 }, 
) 

这里的播放器是我们的类名。我们需要检索一个特定的属性(例如:'name1'的卷号)。你能帮我解决它吗?使用我们已经检索过的max_shoots。我想知道Django查询来检索上述信息。Django查询检索特定属性

回答

0

你可以这样做

player_obj = player.objects.order_by('-Num_baskets').first() 
#do player_obj.roll_no