Changes between Initial Version and Version 3 of Ticket #25861


Ignore:
Timestamp:
Dec 12, 2015, 10:36:51 AM (8 years ago)
Author:
Tim Graham
Comment:

This query seems to work for me:

Article.objects.annotate(
    likes=Count(
        Case(When(articlelike__date__gte=F('pubDate'), then=F('articlelike__id'))),
        distinct=True
    ),
    views=Count(
        Case(When(articleview__date__gte=F('pubDate'), then=F('articleview__id'))),
        distinct=True
    )
)

I've attached the sample project I used for testing.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #25861

    • Property Component UncategorizedDatabase layer (models, ORM)
    • Property Resolutionworksforme
    • Property Status newclosed
  • Ticket #25861 – Description

    initial v3  
    44
    55{{{
    6 class Article(model.Model):
     6class Article(models.Model):
    77    title = models.CharField(max_length=100, null=True)
    88    body = models.TextField(null=True)
Back to Top