-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Description
Release notes:
https://docs.djangoproject.com/en/5.0/releases/5.0/
Passing unsaved model instances to related filters is no longer allowed.
openedx/core/djangoapps/course_groups/tests/test_cohorts.py::TestCohortsAndPartitionGroups::test_delete_cascade - ValueError: Model instances passed to related filters must be saved
def test_delete_cascade(self):
"""
Test that cohort -> partition group links are automatically deleted
when their parent cohort is deleted.
"""
self._link_cohort_partition_group(
self.first_cohort,
self.partition_id,
self.group1_id
)
assert cohorts.get_group_info_for_cohort(self.first_cohort) == (self.group1_id, self.partition_id)
# delete the link
self.first_cohort.delete()
# api should return nothing at that point
> assert cohorts.get_group_info_for_cohort(self.first_cohort) == (None, None)
openedx/core/djangoapps/course_groups/tests/test_cohorts.py:773:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
openedx/core/djangoapps/course_groups/cohorts.py:534: in get_group_info_for_cohort
partition_group = CourseUserGroupPartitionGroup.objects.get(course_user_group=cohort)
../venvs/edxapp/lib/python3.11/site-packages/django/db/models/manager.py:87: in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
../venvs/edxapp/lib/python3.11/site-packages/django/db/models/query.py:619: in get
clone = self._chain() if self.query.combinator else self.filter(*args, **kwargs)
../venvs/edxapp/lib/python3.11/site-packages/django/db/models/query.py:1481: in filter
return self._filter_or_exclude(False, args, kwargs)
../venvs/edxapp/lib/python3.11/site-packages/django/db/models/query.py:1499: in _filter_or_exclude
clone._filter_or_exclude_inplace(negate, args, kwargs)
../venvs/edxapp/lib/python3.11/site-packages/django/db/models/query.py:1506: in _filter_or_exclude_inplace
self._query.add_q(Q(*args, **kwargs))
../venvs/edxapp/lib/python3.11/site-packages/django/db/models/sql/query.py:1643: in add_q
clause, _ = self._add_q(q_object, can_reuse)
../venvs/edxapp/lib/python3.11/site-packages/django/db/models/sql/query.py:1675: in _add_q
child_clause, needed_inner = self.build_filter(
../venvs/edxapp/lib/python3.11/site-packages/django/db/models/sql/query.py:1585: in build_filter
condition = self.build_lookup(lookups, col, value)
../venvs/edxapp/lib/python3.11/site-packages/django/db/models/sql/query.py:1412: in build_lookup
lookup = lookup_class(lhs, rhs)
../venvs/edxapp/lib/python3.11/site-packages/django/db/models/lookups.py:38: in __init__
self.rhs = self.get_prep_lookup()
../venvs/edxapp/lib/python3.11/site-packages/django/db/models/fields/related_lookups.py:103: in get_prep_lookup
self.rhs = get_normalized_value(self.rhs, self.lhs)[0]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
value = <CourseUserGroup: FirstCohort>, lhs = Col(course_groups_courseusergrouppartitiongroup, course_groups.CourseUserGroupPartitionGroup.course_user_group)
def get_normalized_value(value, lhs):
from django.db.models import Model
if isinstance(value, Model):
if not value._is_pk_set():
> raise ValueError("Model instances passed to related filters must be saved.")
E ValueError: Model instances passed to related filters must be saved.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels