How can I ONLY the categories where there is at least one "Post" related??, hope it makes sense!?
**models.py**
class Category(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)
def __unicode__(self):
return self.name
**view.py:**
def index(request):
categories = category.objects.filter( ??? )
How can I ONLY the categories where there is at least one "Post" related??, hope it makes sense!?