I have two models:
class ModelA(models.Model):
name = models.CharField()
class ModelB(models.Model):
a = models.ForeignKey(ModelA)
value = models.CharField()
ModelB always belongs to a ModelA. I have a certain query that filters my ModelBs:
ModelB.objects.filter(value='foo')
From that QuerySet I need to retrieve the matching ModelA set. So I tried this:
>>> ModelB.objects.filter(value='foo').values('a')
[{'a': 2}, {'a': 4}, {'a': 6}]
But as you can see that only got me the object ids. How can I fetch the objects themselves?
If you want ModelAs, you have to ask for ModelAs.