title: Google App Engine circular model dependency in Python
body: <p>I have the following python module:</p>
  
  <pre><code>from google.appengine.ext import db
  from user import User
  
  class Post(db.Model):
      content = db.TextProperty()
      time = db.DateTimeProperty(auto_now_add=True)
      user = db.ReferenceProperty(User)
      topic = db.ReferenceProperty(Topic)
  
  class Forum(db.Model):
      parent_ = db.SelfReferenceProperty()
      name = db.StringProperty()
      description = db.StringProperty()
      topics_count = db.IntegerProperty(default=0)
      posts_count = db.IntegerProperty(default=0)
      last_post = db.ReferenceProperty(Post)
  
  
  class Topic(db.Model):
      forum = db.ReferenceProperty(Forum)
      title = db.StringProperty()
      replies_count = db.IntegerProperty(default=0)
      views = db.IntegerProperty(default=0)
      time = db.DateTimeProperty(auto_now_add=True)
      user = db.ReferenceProperty(User)
      last_post = db.ReferenceProperty(Post)
  </code></pre>
  
  <p>This does not work because I use <code>Topic</code> in <code>Post</code> class. I read <a href="https://stackoverflow.com/questions/6402522/python-mutually-dependent-classes-circular-dependencies/6402530#6402530">this solution</a> and solved the circular dependency problem. The resulting module is as follows:</p>
  
  <pre><code>from google.appengine.ext import db
  from user import User
  
  class Post(db.Model):
      content = db.TextProperty()
      time = db.DateTimeProperty(auto_now_add=True)
      user = db.ReferenceProperty(User)
  
  
  class Forum(db.Model):
      parent_ = db.SelfReferenceProperty()
      name = db.StringProperty()
      description = db.StringProperty()
      topics_count = db.IntegerProperty(default=0)
      posts_count = db.IntegerProperty(default=0)
      last_post = db.ReferenceProperty(Post)
  
  
  class Topic(db.Model):
      forum = db.ReferenceProperty(Forum)
      title = db.StringProperty()
      replies_count = db.IntegerProperty(default=0)
      views = db.IntegerProperty(default=0)
      time = db.DateTimeProperty(auto_now_add=True)
      user = db.ReferenceProperty(User)
      last_post = db.ReferenceProperty(Post)
  
  
  Post.topic = db.ReferenceProperty(Topic)
  </code></pre>
  
  <p>However now I have another problem. App Engine creates <code>Post</code> table, but it does not have topic column. How can I solve this problem? </p>