Return to Snippet

Revision: 10173
at December 11, 2008 03:22 by tamuratetsuya


Initial Code
1. 設定方法

      class MyModelRoot(db.Model):
        text = db.StringProperty()
        date = db.DateTimeProperty(auto_now_add=True)

      class MyModel(db.Model):
        text = db.StringProperty()
        date = db.DateTimeProperty(auto_now_add=True)

      # 親子関係を作らない。
      model = MyModel(text="hoge")

      # 親子関係を作る。
      root = MyModelRoot(text="fuga")
      model = MyModel(parent=root, text="hoge") # parent=root,

   1. parentを指定した取得方法 

"ANCESTOR IS"を使用する。

parentKey = 1
root = MyModelRoot.get_by_id(key)
models = MyModel.gql("WHERE ANCESTOR IS :parent", parent=root)

Initial URL


Initial Description


Initial Title
Googleのデータは親子関係を指定できる  Modelのparent属性で設定できる

Initial Tags
google, python, django

Initial Language
Python