title: How to set a default value from a SQLAlchemy relationship?
body: <p>I have a set of classes defined like this:</p>
  
  <pre><code>class CrosstabCohort(Base):
      __table__ = crosstab_cohorts
      # has property is_column
      cohort = relationship(Cohort, innerjoin=True)
  
  class Crosstab(Base):
      __table__ = crosstabs
  
      columns = relationship(CrosstabCohort,
              #secondary=crosstab_cohorts,
              primaryjoin=and_(
                  crosstabs.c.crosstab_id == crosstab_cohorts.c.crosstab_id,
                  crosstab_cohorts.c.is_column == True),
              order_by=crosstab_cohorts.c.created_at,
              )
  
      rows = relationship(CrosstabCohort,
              #secondary=crosstab_cohorts,
              primaryjoin=and_(
                  crosstabs.c.crosstab_id == crosstab_cohorts.c.crosstab_id,
                  crosstab_cohorts.c.is_column == False),
              order_by=crosstab_cohorts.c.created_at,
              )
  </code></pre>
  
  <p>When I add column or row objects by calling <code>append</code> on the relationship instance, I'd like for the <code>is_column</code> property to be automatically set to either <code>True</code> or <code>False</code> depending upon which relationship I append it to. Is this possible? At present, when I append to these relationships and try to commit, I receive an error from my database that the <code>is_column</code> property is not set. Can this be done automatically or must I set the <code>is_column</code> property on each <code>Cohort</code> object?</p>