title: django class based views for all categories with all entires
body: <p>I have tried this for a couple of hours, and looked at alot of documentation, but I cant get it right. I dont think I'll see a solution to this anytime soon, so maybe someone could see what is wrong?</p>
  
  <p>I want a view to show all my categories and all my connected entries to those categories.</p>
  
  <p>I have tried to follow this example: <a href="https://docs.djangoproject.com/en/dev/topics/class-based-views/generic-display/#dynamic-filtering" rel="nofollow">django class-based-views topic</a></p>
  
  <p>But I get this error: tuple index out of range</p>
  
  <p>My model:</p>
  
  <pre><code>STATUS_CHOICES = (
      ('d', 'Draft'),
      ('p', 'Published'),
      ('w', 'Whitdrawn'),
  )
  
  class PublishedManager(models.Manager):
      use_for_related_fields = True
      def get_query_set(self):
          return super(PublishedManager, self).get_query_set().filter(status='p')
  
  class Category(models.Model):
      name = models.CharField()
      slug = models.SlugField()
      status = models.CharField(max_length=1, default='d', choices=STATUS_CHOICES)
      published = PublishedManager()
  
  class Entry(models.Model):
      name = models.CharField()
      slug = models.SlugField()
      category = models.ForeignKey(Category)
      status = models.CharField(max_length=1, default='d', choices=STATUS_CHOICES)
      published = PublishedManager()
  </code></pre>
  
  <p>My urls</p>
  
  <pre><code>#View for all categories and all connected entries
  url(r'^blog/$', AllCategories.as_view()),
  #View for one category - and all the connected entries
  url(r'^blog/(?P&lt;slug&gt;[-\w]+)/$', CategoryList.as_view()),
  </code></pre>
  
  <p>My views</p>
  
  <pre><code>class AllCategories(ListView):
      context_object_name = "category_list"
      queryset = Category.published.all()
  
  class CategoryList(ListView):
  
      template_name = 'blog/category_and_connected_entries.html'
  
      def get_queryset(self):
          self.category = get_object_or_404(Category, self=self.kwargs['slug'])
          return Entry.published.filter(category=self.category)
  
      def get_context_data(self, **kwargs):
          # Call the base implementation first to get a context
          context = super(CategoryList, self).get_context_data(**kwargs)
          # Add in the category
          context['category'] = self.category
          return context
  </code></pre>
  
  <p>Any help is much appreciated!</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Added my custom manager.
  I only have problems not showing unpublised entires in my template for listing <strong>all</strong> my categories and <strong>all</strong> their connected entires like:
      <ul>
          <li>Category 1
              <ul>
                  <li>Published entry 1</li>
                  <li>Published entry 3</li>
              </ul>
          </li>
          <li>Category 2
              <ul>
                  <li>Published entry 7</li>
                  <li>Published entry 9</li>
              </ul>
          </li>
      </ul>    </p>
  
  <p>I use this for loop getting the connected entires, but it also list the unpublised entires:</p>
  
  <p>{% for entry in category.entry_set.all %}</p>