0

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?

The following answer seems relevant, but is not quite the answer.

how to display parent entity while looping through child entities in Jinja2 template

(I have asked the same question on google groups but then remembered the recommendation to post question here.)

Community
  • 1
  • 1
zerowords
  • 2,915
  • 4
  • 29
  • 44

1 Answers1

0
template_values = {'qs': qs,
            'name': s.name
            }
self.render_template('index.html',  template_values )
zerowords
  • 2,915
  • 4
  • 29
  • 44