title: Django: How to filter and display posts from categories on a page
body: <p>I'm new to Django and have build a simple application that includes posts. I want to display posts that are associated with certain categories on one page. I did quite a bit of research online but can't seem to make it work. I think the problem is in my views.py</p>
  
  <p>I guess there's something wrong with the get_queryset function in CategoryListView.</p>
  
  <pre><code>'''
  models.py 
  '''
  from django.db import models
  
  
  class Post(models.Model):
      title = models.CharField(max_length=100)
      content = models.TextField()
      date = models.DateTimeField(default=timezone.now)
      author = models.ForeignKey(User, on_delete=models.CASCADE)
  
      category = models.ForeignKey(
          'Category', 
          on_delete=models.SET_NULL,
          null=True)
  
      def __str__(self):
          return self.title
  
      def get_absolute_url(self):
          return reverse('post-detail', kwargs={'pk': self.pk})
  
  
  
  class Category(models.Model):
      name = models.CharField(max_length=100)
      slug = models.SlugField(max_length=150, unique=True)
  
      def __str__(self):
          return self.name 
  
      def get_absolute_url(self):
          return reverse('post-category', kwargs={'pk': self.pk})
  
  
  
  
  '''
  views.py
  '''
  from django.views.generic import ListView    
  from .models import Post, Category
  
  
  
  class CategoryListView(ListView):
      model = Post
      template_name = 'posts/post_category.html'
  
      def get_queryset(self):
          category = get_object_or_404(Category,   id=self.kwargs.get('category__name'))
          return Posts.objects.filter(category_name=category)
  
  
  
  
  '''
  urls.py
  '''
  from .views import CategoryListView
  
  
  urlpatterns = [
      # urlpatterns for other pages left out for better readability
      CategoryListView.as_view(), name='post-category')
  ]
  </code></pre>
  
  <p>The code gives me a 404 and the message that no Category matches my query.</p>