Models API
==================

FormAlchemy is aware of the ``__unicode__`` and ``__html__`` methods:

.. sourcecode:: python

  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 '%s (mailto:%s)' % (self.email, self.name)
      def __repr__(self):
          return '<User %s>' % self.name

You can also use the :func:`formalchemy.Column` wrapper to set some extra options:

.. autofunction:: formalchemy.Column

