python - Combining two Google App Engine datastore results? -


i'm trying combine 2 google app engine datastore results. because want list them in template.

for example: other_user_answers = useranswer.gql("where user = :1", user.key()).fetch(500) my_answers = useranswer.gql("where user = :1", me.key()).fetch(500)

i want combine these results based on question.key().id(). can in template:

{% other_user_answer in other_user_answers %}     question #{{other_user_answer.question.key.id}}<br>     user: {{other_user_answer.answer}}     me:  {{other_user_answer.my_answer}} {% endfor %} 

i'm not sure if i'm explaining best way or not! along lines.

also, i'm not quite sure google app engine datastore results come in (like list, dict, etc), i'm not quite sure i'm working with.

edit more explanation: users going answer bunch of questions. when i'm logged site , go different user's page (jimmy). want list of jimmy's answers of answers next well. pull table useranswer , answers me.... , jimmy. have 2 sets of results. want spit them out 1 though based on question id.

like:

favorite color? me: red jimmy: blue

favorite ice cream? me: chocolate jimmy: vanilla

the best solution turn list returned 1 of fetch() operations dict keyed question id. walk on other list , pull value out of dict based on question id, making sure deal missing entries (e.g. questions jimmy answered didn't), , store on attribute (e.g. my_answer). after can pass list template.


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -