Models API

FormAlchemy is aware of the __unicode__ and __html__ methods:

class User(Base):
    """A User model"""
    __tablename__ = 'users'
    id = Column(Integer, primary_key=True)
    email = Column(Unicode(40), unique=True, nullable=False)
    password = Column(Unicode(20), nullable=False)
    name = Column(Unicode(30))
    def __unicode__(self):
        """This is used to render the model in a relation field. Must return an
        unicode string."""
        return self.name
    def __html__(self):
        """This is used to render the model in relation field (readonly mode).
        You need need to clean up the html yourself. Use it at your own
        risk."""
        return '<a href="mailto:%s">%s</a>' % (self.email, self.name)
    def __repr__(self):
        return '<User %s>' % self.name

You can also use the formalchemy.Column() wrapper to set some extra options: