from models import Song
from random import choice

def random_song(genre):
    results = Song.query().filter(Song.genre==genre).fetch()
    print(results)
    songs = choice(results)
    random_song = {
        "title": songs.song,
        "album": songs.album,
        "artist": songs.artist.lower(),
        "genre": genre,
    }
    return random_song

[((7, 12, 7, 27), 'random.choice', 'choice', ({(7, 19, 7, 26): 'results'}, {}), '(results)', False, 'from random import choice\n'), ((5, 14, 5, 26), 'models.Song.query', 'Song.query', ({}, {}), '()', False, 'from models import Song\n')]