KindError: Property r must be an instance of SecondModel, why ?

Posted by zjm1126 on Stack Overflow See other posts from Stack Overflow or by zjm1126
Published on 2010-06-09T07:32:05Z Indexed on 2010/06/09 9:52 UTC
Read the original article Hit count: 147

class FirstModel(db.Model):
    p = db.StringProperty()
    r=db.ReferenceProperty(SecondModel)

class SecondModel(db.Model):
    r = db.ReferenceProperty(FirstModel)

class sss(webapp.RequestHandler):
  def get(self):
    a=FirstModel()
    a.p='sss'
    a.put()
    b=SecondModel()
    b.r=a
    b.put()

    a.r=b
    a.put()
    self.response.out.write(str(b.r.p))

the error is :

Traceback (most recent call last):
  File "D:\Program Files\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 511, in __call__
    handler.get(*groups)
  File "D:\zjm_code\helloworld\a.py", line 158, in get
    a.r=b
  File "D:\Program Files\Google\google_appengine\google\appengine\ext\db\__init__.py", line 3009, in __set__
    value = self.validate(value)
  File "D:\Program Files\Google\google_appengine\google\appengine\ext\db\__init__.py", line 3048, in validate
    (self.name, self.reference_class.kind()))
KindError: Property r must be an instance of SecondModel

thanks

© Stack Overflow or respective owner

Related posts about python

Related posts about google-app-engine