我有一个具有结构化属性的主要属性。我在结构化属性中定义了一个属性,它需要访问父属性的值。我尝试的语法是self.key.parent().email
,但这并没有成功。我怎样才能做到这一点?
class Individual(ndb.Expando):
name = ndb.StringProperty()
email = ndb.StringProperty()
team_list = ndb.StructuredProperty(IndividualTeam, repeated=True)
class IndividualTeam(ndb.Model):
team_key = ndb.KeyProperty()
fundraise_amt = DecimalProperty()
@property
def donation_total(self):
#This is my problem here
return self.key.parent().email