title: Django select distinct
body: <p><strong>models.py</strong></p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong>view.py:</strong></p>
  
  <pre><code>def index(request):
      posts = Post.objects.filter(genders=1)
  
      categories = Category.objects.filter(post__genders=1)
                                   .exclude(post=None).order_by('-sort')
  </code></pre>
  
  <p>Why do I get the same category 3 times if there are 3 posts where gender is equal to 1?? I only need the category 1 time i my select like "select distinct" - how can I do so??</p>