开发者

Appengine reference order

I have declared models in AppEngine's models.py:

class Post(db.Model):
topic = db.ReferenceProperty(Topic, collection_name='posts', verbose_name=_('Topic'))
(..)

class Topic(db.Model):
(..)
last_post = db.R开发者_如何学运维eferenceProperty(Post, collection_name='last_topic_post')

Problem is ReferenceProperty must have Model class but Topic class is undeclared when declaring Post. The same will happen with Post class after switch. How to solve this?

Thanks.


ReferenceProperty accepts None in place of a model class, which means "no type restriction" on that field. It is not a nice solution, however.

See:

http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html#ReferenceProperty

Having such cyclic references in your model is not a good idea IMHO. You should find your last_post on demand instead of storing a reference to it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜