Django queryset return true if the object was created on the last month
So I'm trying to make this query:
queryset = (
Offer.objects.annotate(
is_new=Case(
When(
created_at__month=[
now.month
],
then=Value("True"),
),
default=Value("False"),
)
)
.values("is_new")
)
Basically what i want is to return a new booleand field that tells me "true" if the offer was created on the last month. But I'm getting the following error:
TypeError: Field 'None' expected a number but got [1].
Does anyone know why this happens? or how can I fix it? Also I thank you If you have a better approach.
Thanks in advance :)