from datetime import datetime
from ..extensions import db


class List(db.Model):
    __tablename__ = 'lists'

    id = db.Column(db.Integer, primary_key=True)
    created_at = db.Column(db.DateTime, default=datetime.utcnow())
    name = db.Column(db.String(50), nullable=False)
    todos = db.relationship('Todo', backref='list', lazy='dynamic')

    def to_json(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}

    def from_json(self, json):
        if 'name' in json:
            self.name = json['name']
        return self

@@ -334,15 +334,14 @@
 zy='
-dynamic
+joined
 ')%0A%0A
@@ -371,22 +371,22 @@
         
-return
+json =
  %7Bc.name
@@ -441,16 +441,100 @@
 columns%7D
+%0A        json%5B'todos'%5D = %5Btodo.to_json() for todo in self.todos%5D%0A        return json
 %0A%0A    de

add todos to list to_json method