GAE/Django Templates (0.96) filters to get LENGTH of GqlQuery and filter it
- by Halst
I pass the query with comments to my template:
COMM = CommentModel.gql("ORDER BY created")
doRender(self,CP.template,{'CP':CP,'COMM':COMM, 'authorize':authorize()})
And I want to output the number of comments as a result, and I try to do things like that:
<a href="...">{{ COMM|length }} comments</a>
Thats does not work (yeah, since COMM is GqlQuery, not a list). What can I do with that? Is there a way to convert GqlQuery to list or is there another solution? (first question)
Second question is, how to filter this list in template? Is there a construct like this:
<a href="...">{{ COMM|where(reference=smth)|length }} comments</a>
so that I can get not only the number of all comments, but only comments with certain db.ReferenceProperty() property, for example.
Last question: is it weird to do such things using templates?