Skip to content

Commit

Permalink
Merge pull request #1998 from mkurek/squash-migrations
Browse files Browse the repository at this point in the history
handle target object does not exist in imported obj
  • Loading branch information
mkurek committed Nov 26, 2015
2 parents 4fbcdfb + b63e24b commit 4963cea
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ralph/data_importer/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ def get_object_from_old_pk(cls, model, old_pk):
except cls.DoesNotExist:
raise ImportedObjectDoesNotExist()
else:
return model.objects.get(id=imported_obj.object_pk)
try:
return model.objects.get(id=imported_obj.object_pk)
except model.DoesNotExist:
raise ImportedObjectDoesNotExist(
'Target object does not exist (it was probably removed)'
)

@classmethod
def create(cls, obj, old_pk):
Expand Down

0 comments on commit 4963cea

Please sign in to comment.