Suppose I have the following two models:
class A(models.Model):
name = models.CharField(max_length = 20)
type = models.CharField(max_length = 20)
class B(models.Model):
name = models.CharField(max_length = 20)
type = models.CharField(max_length = 20)
a = models.ForeinKey(A)
I want such A instances:
- Its name is 'name_a' and its type is 'type_a'
- It has at least one B objects related to it whose name is 'name_b' and whose type is 'type_b'
Is there a way to get such A instances at one time?