diff --git a/cds/api/v1/services.py b/cds/api/v1/services.py index 4246bb6b..df1a3a5b 100644 --- a/cds/api/v1/services.py +++ b/cds/api/v1/services.py @@ -407,7 +407,8 @@ def getExpiredCds(yearfrom=None, coursetypes=None): aa_reg_did__lt=settings.CURRENT_YEAR, ) .exclude(stato_regdid_cod="R") - .select_related("cds") + # exclude courses that have finished their regular life cycle + .exclude(aa_reg_did__lte=(settings.CURRENT_YEAR - F("cds__durata_anni"))) .values("aa_reg_did", "cds__cds_cod", "cds__durata_anni") )