Skip to content

Instantly share code, notes, and snippets.

@ShinJJang
Created October 14, 2013 14:51
Show Gist options
  • Save ShinJJang/abde260e4f40e9962173 to your computer and use it in GitHub Desktop.
Save ShinJJang/abde260e4f40e9962173 to your computer and use it in GitHub Desktop.
django object join exam using foreign key reverse
"""
Purpose for exact match, but this's Partial matches
"""
pks = [ "1", "2", "3", "4" ]
query = reduce(operator.and_, [ Q(comments__pk=x) for x in pks ] )
bundle.data['answer'] = Posts.objects.filter(query).distinct()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment