from flask import Blueprint, render_template, request, jsonify
from sqlalchemy import func

from skylines.model import Club
from skylines.lib.vary import vary

clubs_blueprint = Blueprint('clubs', 'skylines')


@clubs_blueprint.route('/')
@vary('accept')
def index():
    if 'application/json' not in request.headers.get('Accept', ''):
        return render_template('ember-page.jinja', active_page='settings')

    clubs = Club.query().order_by(func.lower(Club.name))

    name_filter = request.args.get('name')
    if name_filter:
        clubs = clubs.filter_by(name=name_filter)

    json = []
    for c in clubs:
        json.append({
            'id': c.id,
            'name': unicode(c),
        })

    return jsonify(clubs=json)

@@ -151,16 +151,56 @@
 ort vary
+%0Afrom skylines.schemas import ClubSchema
 %0A%0Aclubs_
@@ -625,155 +625,99 @@
     
-json = %5B%5D%0A    for c in clubs:%0A        json.append(%7B%0A            'id': c.id,%0A            'name': unicode(c),%0A        %7D)%0A%0A    return jsonify(clubs=json
+return jsonify(clubs=ClubSchema(strict=True, only=('id', 'name')).dump(clubs, many=True).data
 )%0A

Use ClubSchema class for serialization