title: using Case in django
body: <p>I am trying to display the value A,B,C or D as per the total of a blogger. But I am getting the error - Cannot resolve keyword 'total' into field.Can someone suggest the correct way of doing it. Thanks</p>
  
  <p>models.py</p>
  
  <pre><code>class Blog(models.Model):
  
       author = models.ForeignKey(User, on_delete = models.CASCADE, related_name='blogs') 
       likes  = models.ManyToManyField(User, blank=True, related_name='blog_likes')
       title = models.CharField(max_length=100)
  
       def total_likes_received(user):
            return user.blogs.aggregate(total_likes=Count('likes'))['total_likes'] or 0
  
       @property
       def total(self):
           return count(self.author.title) + count(self.author.likes)
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>def get_queryset(self):
      return (Blog.objects.filter(date__lte=timezone.now())
                                      .order_by('date')
                                      .annotate(
                  name=Case(
                        When(total__gt=0,total__lte=11, then=Value('B')),
                        When(total__gt=10,total__lte=21, then=Value('C')),
                        When(total__gt=20,total__lte=31, then=Value('D')),
                        default=Value('A'),
                        output_field=CharField(),
                           ),
                                                ).values_list('name')
              )
  </code></pre>