2011-04-06 2 views
3

나는 현재 GAE를 테스트하고 나는 몇 가지 문제가 데이터 저장소에 적응하는 데 문제 ... 예 모델을 감안할 때신참 앱 엔진 데이터 저장소 질문 - 모델 및 .filter()

:

class Category(db.Model): 
     name = db.StringProperty() 
     date_time = db.DateProperty(auto_now_add=True) 

    class Link(db.Model): 
     category = db.ReferenceProperty(Category, collection_name='links') 
     name = db.StringProperty() 
     date_time = db.DateProperty(auto_now_add=True) 
     link = db.LinkProperty() 
     type = db.StringProperty(choices=set(["in", "out"])) 

및 작동하지 코드 :

category = Category.get(key) 
link = category.links.filter('type=', 'in').get() 

그것이 내가이 참조 된 부동산에()를 필터링 할 수없는 나는 것 같다 ... 이상한 일이다 category.lin 그 KS

어떤 도움을 환영합니다 ...는 쿼리 객체는 ... category.links을 반복하고 유형을 속성을 확인 할 수 있습니다 하지만 나는 더 나은 방법이 있다는 것을 확신 사전에 감사하는

답변

4

귀하의 코드는 괜찮습니다, 그냥

link = category.links.filter('type =', 'in').get() 
type 사이 =을 공백을 넣어
관련 문제