I'm using Django and Python 3.7. I want to write a Coalesce expression to help me write a larger Django query. I have
Coalesce(
F("votes")
-
Subquery(relevant_hour_stats.values('votes_threshold')[:1]),
output_field=models.FloatField())
Here is the expression in context ...
qset = (
ArticleStat.objects
.all()
.annotate(
shifted_article_create_hour=ExtractHour(ExpressionWrapper(
F('article__created_on')
+
timedelta(seconds=avg_fp_time_in_seconds),
output_field=models.DateTimeField()
))
)
.annotate(
votes_above_threshold=(
Coalesce(
F("votes")
-
Subquery(relevant_hour_stats.values('votes_threshold')[:1]),
output_field=models.FloatField())
),
)
.filter(
votes_above_threshold__gt=0,
)
)
but this is resulting in a
Coalesce must take at least two expressions
complaining about the line
output_field=models.FloatField()
as far as I can tell, I have two expressions. What else could the error be referring to?