django - How do I compare a CombinedResponse object value with an int? -
i'm trying annotate query percentage repsents how "complete" business logic is. don't want percentage go on 100%. have in query:
.annotate(completion=max(100, count('id')/f('something_tricky') )
the issue count/f
combinedexpression
, unorderable, can't used in max
. won't let me cast int
either:
int() argument must string, bytes-like object or number, not 'combinedexpression'
or string.
how completion
value int out of query?
you must use database functions annotations, in case greatest function.
from django.db.models import value django.db.models.functions import greatest .annotate(completion=greatest(value(100), count('id')/f('something_tricky') )
Comments
Post a Comment