我有以下 python 模块:
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)
这不起作用,因为我Topic
在Post
课堂上使用。我阅读了这个解决方案并解决了循环依赖问题。生成的模块如下:
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)
但是现在我有另一个问题。App Engine 创建Post
表,但它没有主题列。我怎么解决这个问题?