2017-02-24 90 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