[Answered ]-Django annotate with dynamic "then" value

1👍

Yes, you can work with:

queryset = queryset.annotate(
    last_installment_month_as_string=Case(
        *[
            When(last_installment_month=key, then=Value(value))
            for key, value in MONTHS.items()
        ]
    )
)

Leave a comment