class Domains(models.Model):
name = models.CharField(max_length=30)
description = models.CharField(max_length= 60)
user = models.ManyToManyField("Users", blank=True, null=True)
def __unicode__(self):
return self.name
class Groups(models.Model):
domain = models.ForeignKey(Domains)
name = models.CharField(max_length=30)
description = models.CharField(max_length= 60)
def __unicode__(self):
return self.name
class Users(models.Model):
login = models.CharField(max_length=30, unique=True)
group = models.ManyToManyField(Groups, blank=True, null=True)
def __unicode__(self):
return self.login
I have the model above. Needed some assistance working with Django ORM. How would I build a query the returns all the Group names that belong to only those Domains to which a User belongs