Skip to content

Commit

Permalink
Provide more info about missing content type.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkuty committed May 29, 2016
1 parent 64a4cc1 commit 6dbab46
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions horizon_contrib/common/content_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ def get_class_from_ct(name):

parse = name.split('.')

if len(parse) > 1:
return ContentType.objects.get(
app_label=parse[0], model__iexact=parse[1]).model_class()
else:
return ContentType.objects.get(model__iexact=parse[0]).model_class()
try:
if len(parse) > 1:
return ContentType.objects.get(
app_label=parse[0], model__iexact=parse[1]).model_class()
else:
return ContentType.objects.get(
model__iexact=parse[0]).model_class()
except ContentType.DoesNotExist:
raise Exception('Missing model {} in {} app'.format(*parse))

return None

Expand Down

0 comments on commit 6dbab46

Please sign in to comment.