0
키를 비교하는 쿼리를 만들려고하는데 결과가 없습니다.ndb의 KeyProperty와 키 비교
자습서 및 장 모델이 있습니다. Model contais keyproperty of kind Tutorial 장. 키 (Key('Tutorial', 1)
)을 (tutKey = ndb.KeyProperty(kind='Tutorial')
)
tutID = self.request.cookies.get('tut_id', '')
tutIns = ndb.Key('Tutorial', int(tutID)).get()
chaps = Chapter.query(Chapter.tutKey == tutIns.key)
self.render('editTut.html', chaps=chaps, tutins=tutIns.key)
나는 인스턴스가 작동하고 있는지 단지 테스트 tutIns.key
을 보내고있다, 그리고 예 그것은 반환합니다. 또한 나는 단지 쿼리를 Chapter.query()로 만들면 예상대로 모든 장을 반환합니다.
그리고 이것은 내가 장에 tutkey를 저장하고 어떻게 : 내가 1 장과 2 장에 저장된 tutkey이 같은 키 있음을 볼 수있는 개발 콘솔에서
tutID = self.request.cookies.get('tut_id', '')
tutorial = ndb.Key('Tutorial', tutID)
.
.
.
chap = Chapter(tutKey=tutorial, title=title, content=content,
note=note, order=order)
chap.put()
,하지만 키가 아닌 튜토리얼 키와 같습니다. 나는 장을 잘못 만들고있다?
tutIns = ndb.Key('Tutorial', int(tutID)).get()
를하지만 여기, 당신은 문자열로 사용하고 있습니다 : 여기
... 감사합니다! – mFontoura