I have a SQLAlchemy model like this:
class Group(Base):
__tablename__ = 'groups'
id = Column(Integer, primary_key = True, ca_include = True)
name = Column(String, ca_include = True)
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key = True, ca_include = True)
name = Column(String, ca_include = True)
group_id = Column(Integer, ForeignKey('groups.id'), nullable = True, ca_include = True)
group = relationship('Group', ca_include = True)
The form library I used is deform. I installed ColanderAlchemy to convert the model definition into Colander Schema automatically:
form = deform.Form(SQLAlchemyMapping(Group), use_ajax = True)
And I can do form.render() to get a empty form. But how to fill this empty form with a record? I tried:
group = Group.get(1)
form.render(group)
But failed. I also followed this blog but it can only convert a single record into colander's format but no relationship would be converted. So... is there anyway for me to convert the SQLAlchemy record into Colander record?