title: Django blog post by authors
body: <p>I am building a blog in django 3. I want to filter all posts by author and display the results in author page. I can't seem to figure what is wrong with my code. Please help. If i can get an explaination on what is wrong with my code, that will be appreciated.</p>
  
  <p><strong>Views.py</strong></p>
  
  <pre><code>class AuthorPostListView(ListView):
      model = Post
      paginate_by = 5
      template_name = 'author_post.html'
  
      def get_queryset(self):
          return Post.objects.filter(author = self.request.user).order_by('created_on').reverse()
  
      def get_context_data(self):
          context = super(AuthorPostListView, self).get_context_data(**kwargs)
          context['authorpost_list'] = Post.objects.all()
          return context
  </code></pre>
  
  <p><strong>Models.py</strong></p>
  
  <pre><code>class Post(models.Model):
      title           = models.CharField(max_length=200)
      post_slug       = models.SlugField(max_length = 200, unique = True)
      body            = models.TextField()
      created_on      = models.DateTimeField(auto_now_add=True)
      last_modified   = models.DateTimeField(auto_now = True)
      author          = models.ForeignKey(
                          settings.AUTH_USER_MODEL,
                          on_delete=models.CASCADE,
                          related_name = 'blog_posts',
                          )
      post_picture    = models.ImageField(
                          upload_to = 'post_picture', 
                          null = True, 
                          blank = True,
                          default='/media/post_picture/2.jpg',
                          )
      approved_comment = models.BooleanField(default=True)
      tags            = TaggableManager()
      categories      = models.ManyToManyField('Category', related_name = 'posts')
  
      def approve(self):
          self.approved_comment = True
          self.save()
  
      class Meta:
          ordering = ['created_on']
  
      def __str__(self):
          return self.title
  
      def get_absolute_url(self):
          return reverse('post_detail', args=[str(self.id)])
  
      def save(self, *args, **kwargs):
          self.slug = slugify(self.title)
          super(Post, self).save(*args, **kwargs)
  </code></pre>
  
  <p><strong>Template</strong></p>
  
  <pre><code>{% for object in authorpost_list %}
      {{ object.title }}
  {% endfor %}
  </code></pre>
  
  <p><strong>urls.py</strong></p>
  
  <pre><code>urlpatterns = [
  
      path('author_post/', views.AuthorPostListView.as_view(), name = 'author_posts'),
  ]
  </code></pre>