title: SQLAlchemy Generic Relationship simple example
body: <p>I know similar questions have been asked, however I am really struggling to understand how generic fields are implemented in SQLAlchemy.</p>
  
  <p>I have a Permissions class/table which I want to contain a field which can relate to any model type.</p>
  
  <p>I have looked at the examples and this blog post <a href="http://techspot.zzzeek.org/2007/05/29/polymorphic-associations-with-sqlalchemy/" rel="noreferrer">http://techspot.zzzeek.org/2007/05/29/polymorphic-associations-with-sqlalchemy/</a></p>
  
  <p>Is it possible to have a generic relation without a separate table? Just by storing the object_type and id? Something along these lines:</p>
  
  <pre><code>class Permission(AbstractBase):
      user = relationship("User", backref=backref('permissions'))
      permission_type = column(String())
      object = #The object the permission applies to, could be any type.
  </code></pre>
  
  <p>I guess just a really simple example would be appreciated!</p>
  
  <p>Also, it's worth noting I am coming from a Django background!</p>
  
  <p>Thanks</p>