【问题标题】:Create an instance of an entity within same entity in Google App Engine python ndb在 Google App Engine python ndb 中的同一实体中创建实体的实例
【发布时间】:2014-08-24 11:04:46
【问题描述】:

如何在同一实体中创建实体的实例。我想要的是:

class User(ndb.model):
    friends = ndb.StructuredProperty( User, repeated=True )

【问题讨论】:

    标签: python-2.7 google-app-engine google-cloud-datastore app-engine-ndb


    【解决方案1】:

    模型创建后可以动态更新:

    class User(ndb.Model):
      pass
    
    User.friends = ndb.StructuredProperty(User, repeated=True)
    User._fix_up_properties()
    

    _fix_up_properties 来源描述:

    def _fix_up_properties(cls):
        """Fix up the properties by calling their _fix_up() method.
        Note: This is called by MetaModel, but may also be called manually
        after dynamically updating a model class.
        """
    

    【讨论】:

      猜你喜欢
      • 2013-01-05
      • 1970-01-01
      • 2012-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多