嗨,我需要从两个表中获取数据,外键中第一个的 Id 用于其他
这是我的代码
def allplayers(request):
cursor = connection.cursor()
player_list = myplayer.objects.all()
get_player_vital=[]
for i in player_list:
get_player_vital = [vitals.objects.filter(playerID =i.id )]
paginator = Paginator(player_list, 25) # Show 25 contacts per page
page = request.GET.get('page')
try:
contacts = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
contacts = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
contacts = paginator.page(paginator.num_pages)
return render_to_response('allplayers.html', {"contacts": contacts,'get_player_vital':get_player_vital})
当我在模板中打印 get_player_vital 时,它只返回最后一条记录