I have one-to-many model scheme. All seems correct, data population works but linkitem_set.fetch fails with:
AttributeError: '_ReverseReferenceProperty' object has no attribute 'fetch'
There also one question here on SO with the same error but without solution. My code below:
class Project(db.Model):
name = db.StringProperty()
class LinkItem(db.Model):
url = db.StringProperty()
project = db.ReferenceProperty(Project)
class Show(webapp2.RequestHandler):
def get(self):
links = Project.linkitem_set.fetch(100)
self.response.headers['Content-Type'] = 'text/plain'
for li in links:
self.response.out.write(li + '/r/n')
class PopulateDb(webapp2.RequestHandler):
def get(self):
prj = Project(name = 'SomeProject 1')
prj.put()
for i in range(1000):
rlink = random.betavariate(1, 2)
link = LinkItem(url = str(rlink), project = prj)
link.put()
I'm using Python 2.7 and tested this localy and hosted.