'validate course id field'

def clean_course_id(self):

    course_id = self.cleaned_data['course_id']
    try:
        course_key = CourseKey.from_string(course_id)
    except InvalidKeyError:
        try:
            course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
        except InvalidKeyError:
            raise forms.ValidationError(_('Invalid    course    id'))
    return course_key
