Including referenced entity's values in template variable list in jinja2

9 views
Skip to first unread message

thebrianschott

unread,
Jun 15, 2012, 6:13:03 PM6/15/12
to google-a...@googlegroups.com

I have been trying to use a template which prints out entity values from my model QA and also a couple of values from its parent environment's entity which has the model PQ. In particular, the code I have supplied works as is, but it does not allow me to include values from s such as s.name because s.name is not in qs. I have attempted to use the commented out line, for example (# qs["name"] = s.name) but I get the error "TypeError: 'Query' object does not support item assignment".

class MainPage(BaseHandler):

   
def get(self):
        s
= PQ()
        s
.name = "CCD1"
        s
.owner = user
        s
.put()
        q
= QA()
        q
.survey = s
        q
.question = "If we dress up?"
        q
.answers = [0, 0, 0]
        q
.seqnum = float(100)
        q
.put()
        qs
= QA.all()
       
# qs["name"] = s.name
       
self.render_template('index.html',  {'qs': qs})


Can anyone suggest a way to accomplish this, please?
Reply all
Reply to author
Forward
0 new messages