Are you sure it doesn't already throw an error? CourseEnrollment requires course_id to be a CourseKey; so, the get should throw an assertion error from xmodule_django.models.CourseKeyField.get_prep_value