django foreign key relation lookup
django, foreign-key-relationship, python
Solution
Close. You need to specify which field you're spanning across.
Post.objects.filter(posttag__tag=tag)
Problem
Given the following models: ``` class Post(models.Model): title = models.CharField(max_length=200) html = models.TextField() class PostTag(models.Model): post = models.ForeignKey('Post') tag = models.CharField(max_length=200) ``` I want to accomplish looking up a Post based on a given PostTag. So if I had two posts, A and B, tagged as "foo", I want to be able to look up all posts with that tag and get the posts A and B back. I image the query would look something like the following: ``` posts = Post.objects.filter(tag=tag) ``` Any tips on where to start to accomplish this?