**models.py**
class Category(models.Model):
name = models.CharField(max_length=50)
def __unicode__(self):
return self.name
class Gender(models.Model):
name = models.CharField(max_length=50)
def __unicode__(self):
return self.name
class Post(models.Model):
name = models.CharField(max_length=50)
categories = models.ManyToManyField(Category)
genders = models.ManyToManyField(Gender)
def __unicode__(self):
return self.name
**view.py:**
def index(request):
posts = Post.objects.filter(genders=1)
categories = Category.objects.exclude(outlet=None).filter( ?????? ).order_by('-sort'),
Now I need to select ONLY the the categories where there are postes in, depending on the given filter "genders=1" How can I do so?
Hope you understand my issue.