Last active
June 24, 2019 14:40
-
-
Save walison17/ee32185d4efd110638a0a575d8c0b355 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db.models import Case, Value, When, F | |
from django.db.models.functions import Cast | |
result = ( | |
Live | |
.objects | |
.annotate( | |
like_frequence=Case( | |
When(like__gt=0, then=Cast('unlike', models.DecimalField()) / F('like')), | |
default=Value(0), | |
output_field=models.DecimelField() | |
) | |
) | |
.filter(like_frequence__lt=0.2) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment