Skip to content
Snippets Groups Projects
Commit 02be16df authored by Taranjeet Singh's avatar Taranjeet Singh
Browse files

Handle exception while saving course display name.

This commit introduces error check for a special case
where the root course does not exists and a data migration
is attempting to save it.
parent 27cf027a
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
from __future__ import unicode_literals
from django.db import migrations
from django.http import Http404
import json
import logging
......@@ -28,7 +29,11 @@ def save_display_name(apps, schema_editor):
# Create `display_name` overrides for these CCX courses
for ccx in ccx_list:
course = get_course_by_id(ccx.course_id, depth=None)
try:
course = get_course_by_id(ccx.course_id, depth=None)
except Http404:
log.error('Root course %s not found. Skipping saving course display name', ccx.course_id)
continue
display_name = course.fields['display_name']
display_name_json = display_name.to_json(ccx.display_name)
serialized_display_name = json.dumps(display_name_json)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment