From 943557e453baa0d518fc591dfbccfbd1a3707fc2 Mon Sep 17 00:00:00 2001 From: awais qureshi Date: Mon, 18 Aug 2025 23:11:03 +0500 Subject: [PATCH 1/2] fix: Passing unsaved model instances to related filters is no longer allowed. --- openedx/core/djangoapps/course_groups/cohorts.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/openedx/core/djangoapps/course_groups/cohorts.py b/openedx/core/djangoapps/course_groups/cohorts.py index cb3dfc5b9e88..6e1f04efdc13 100644 --- a/openedx/core/djangoapps/course_groups/cohorts.py +++ b/openedx/core/djangoapps/course_groups/cohorts.py @@ -522,6 +522,10 @@ def get_group_info_for_cohort(cohort, use_cached=False): use_cached=True to use the cached value instead of fetching from the database. """ + if cohort.pk is None: + # Object not saved yet, skip caching + return (None, None) + cache = RequestCache("cohorts.get_group_info_for_cohort").data cache_key = str(cohort.id) From 1fbbffc5947f8b6f0e76d34f2a37a79080da0ed2 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Tue, 19 Aug 2025 21:22:31 +0500 Subject: [PATCH 2/2] chore: fix the comment. --- openedx/core/djangoapps/course_groups/cohorts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openedx/core/djangoapps/course_groups/cohorts.py b/openedx/core/djangoapps/course_groups/cohorts.py index 6e1f04efdc13..5bded799fdb9 100644 --- a/openedx/core/djangoapps/course_groups/cohorts.py +++ b/openedx/core/djangoapps/course_groups/cohorts.py @@ -523,7 +523,7 @@ def get_group_info_for_cohort(cohort, use_cached=False): database. """ if cohort.pk is None: - # Object not saved yet, skip caching + # Cohort not saved yet, so no PartitionGroup can be linked to it. return (None, None) cache = RequestCache("cohorts.get_group_info_for_cohort").data