Reputation: 20409
I have the following code, which works well:
comments = PersonComment.gql('WHERE ANCESTOR IS :parent AND verified=True ORDER BY added DESC', parent=person_key).fetch(PAGE_SIZE_COMMENTS+1, (page)*PAGE_SIZE_COMMENTS)
I want to replace that with:
comments = db.Query(PersonComment)
comments.ancestor(person_key)
comments.filter('verified = ', True)
comments.order('-added')
comments.fetch(PAGE_SIZE_COMMENTS+1, (page)*PAGE_SIZE_COMMENTS)
But it doesn't work. What is wrong there?
Upvotes: 1
Views: 111
Reputation: 12838
fetch
returns a result set; comments
is still a Query object. You can do this:
comments = comments.fetch(PAGE_SIZE_COMMENTS+1, (page)*PAGE_SIZE_COMMENTS)
Or call your query object something else to avoid confusion.
As an aside, using fetch with an offset for pagination is really inefficient. Consider using query cursors.
Upvotes: 5