I'm not sure how best to go about this. I have the following @property
method on my Modal:
@property
def check_ins(self):
return SurfCheckIn.objects.filter(surf_waiver=self)
However, I would like to return this compited property in my values()
of a queryset. I thought of using a SubQuery annotation:
queryset = self.get_queryset().filter(
performance_datetime__year=date.year,
performance_datetime__month=date.month,
performance_datetime__day=date.day,
void_type='0'
).exclude(
surf_code='SPECTATOR'
).order_by(
'performance_datetime'
).annotate(
surf_check_ins=SubQuery()
).values()
But I'm not sure where to take the SubQuery from here? What would be the most sensible approach to retrieve that @property
inside an annotation?