본문 바로가기
카테고리 없음

1.[기능] 리그오브레전드 최근 게임 통계

by 모아모아 리뷰 2023. 11. 13.
반응형

사용자에게 더 많은 정보를 제공하기 위하여 최근 게임 플레이 기록을 보여주기 위함.

 

result.html

!-- 최근 게임 통계 섹션 추가 -->
<h2>최근 게임 통계</h2>
<ul>
    {% for game in recent_games %}
    <li style="display: flex; align-items: center; gap: 10px;">
        <strong>{{ game.queueType }}</strong>
        <br>
        <span>
            결과: {% if game.win %} 승리 {% else %} 패배 {% endif %}<br>
            플레이 시간: {{ game.gameDuration|time_format }}<br>
            챔피언: {{ game.championName }}<br>
            K/D/A: {{ game.kills }}/{{ game.deaths }}/{{ game.assists }}
        </span>
    </li>
    {% endfor %}
</ul>

 

views.py

from django.shortcuts import render
from yourapp.models import RecentGame  # 최근 게임 정보를 담은 모델을 import

def summoner_detail(request, summoner_name):
    summoner_data = get_summoner_data(summoner_name)
    league_data = get_league_data(summoner_data['id'])

    # 최근 게임 정보 가져오기 (예시로 최근 5게임 가져오도록 함)
    recent_games = RecentGame.objects.filter(summoner_id=summoner_data['id']).order_by('-timestamp')[:5]

    context = {
        'summoner_data': summoner_data,
        'league_data': league_data,
        'recent_games': recent_games,
    }

    return render(request, 'result.html', context)

RecentGame 모델은 최근 게임에 대한 정보를 저장

RecentGame 모델을 프로젝트에 추가하고 마이그레이션을 수행

이렇게 되면 최근 게임 통계를 데이터베이스에서 가져와 템플릿으로 전달

반응형

최근댓글

최근글

skin by © 2024 ttutta