Skip to content

Instantly share code, notes, and snippets.

@ghoshabhi
Last active July 28, 2016 06:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghoshabhi/9d016c1c6f94ce0cbe7cfa6a7d83a979 to your computer and use it in GitHub Desktop.
Save ghoshabhi/9d016c1c6f94ce0cbe7cfa6a7d83a979 to your computer and use it in GitHub Desktop.
def sampleJoin():
posts = Post.query(Post.is_draft == False).order(-Post.created)
all_users = User.query()
list_dict = []
for p in posts:
p_dict = {}
for u in all_users:
if p.user == u.key:
p_dict['p_id'] = p.key.id()
p_dict['p_title'] = p.title
p_dict['p_content'] = p.content
p_dict['p_created'] = p.created
p_dict['a_name'] = u.fullname
p_dict['a_key'] = u.key
p_dict['a_id'] = u.key.id()
list_dict.append(p_dict)
return list_dict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment