def get_context_data(self, **kwargs): context = super(LobbyView, self).get_context_data(**kwargs) available_games = [{ "creator": game.creator.username, "id": game.pk } for game in Game.get_available_games()] completed_games = Game.get_available_games() player_games = Game.get_games_for_player(self.request.user) return context
def get_context_data(self, **kwargs): context = super(LobbyView, self).get_context_data(**kwargs) # get current open games to prepopulate the list # we're creating a list of games that contains just the id (for the link) and the creator available_games = [{ 'creator': game.creator.username, 'id': game.pk } for game in Game.get_available_games()] past_games = Game.get_available_games() # for the player's games, we're returning a list of games with the opponent and id player_games = Game.get_games_for_player(self.request.user) return context