From 98f4756d0977aeff7e7c37ec95ba2b73a666f26b Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Wed, 20 Aug 2025 11:16:20 +0500 Subject: [PATCH] =?UTF-8?q?fix:=20Passing=20unsaved=20model=20instances=20?= =?UTF-8?q?to=20related=20filters=20is=20no=20longer=20=E2=80=A6=20(#37227?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 cb3dfc5b9e..5bded799fd 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: + # Cohort not saved yet, so no PartitionGroup can be linked to it. + return (None, None) + cache = RequestCache("cohorts.get_group_info_for_cohort").data cache_key = str(cohort.id)