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)