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

[((167, 182), 'random.choice', 'choice', (['results'], {}), '(results)\n', (173, 182), False, 'from random import choice\n'), ((89, 101), 'models.Song.query', 'Song.query', ([], {}), '()\n', (99, 101), False, 'from models import Song\n')]