Posted By


tamuratetsuya on 12/09/08

Statistics


Viewed 463 times
Favorited by 0 user(s)

ReferencePropertyのときの外部キーからの検索


/ Published in: Python
Save to your folder(s)

みたいなカンジで「保持するmodel名の小文字+"_set"」でぶらさがるEntityのリストを取得できる。この名称はReferencePropertyのコンストラクタのcollection_name引数で指定する事もできる。


Copy this code and paste it in your HTML
  1. class MyModel1(db.Model):
  2. text = db.StringProperty()
  3.  
  4. class MyModel2(db.Model)
  5. text = db.StringProperty()
  6. myModel1 = db.ReferenceProperty(MyModel1)
  7.  
  8. myModel1 = MyModel1.get_by_id(1)
  9. myModel2s = MyModel1.mymodel2_set

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.