aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/utils/model_meta.py
diff options
context:
space:
mode:
authorCarlton Gibson2014-12-01 11:22:39 +0100
committerCarlton Gibson2014-12-01 11:22:39 +0100
commitef26f43de4a0c9ac3081c06a383b5d3d4d007797 (patch)
treebf6abcd15f0e58f4fa79a83cd4e051b8987dd311 /rest_framework/utils/model_meta.py
parentc50a42bddc66e28d624cd3caadd2d63502ac2e6e (diff)
parent72c4ec4e189796e506655e275cd9c77abe98e1b9 (diff)
downloaddjango-rest-framework-ef26f43de4a0c9ac3081c06a383b5d3d4d007797.tar.bz2
Merge branch 'master' of github.com:tomchristie/django-rest-framework
Diffstat (limited to 'rest_framework/utils/model_meta.py')
-rw-r--r--rest_framework/utils/model_meta.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/rest_framework/utils/model_meta.py b/rest_framework/utils/model_meta.py
index 82361edf..c98725c6 100644
--- a/rest_framework/utils/model_meta.py
+++ b/rest_framework/utils/model_meta.py
@@ -6,6 +6,7 @@ relationships and their associated metadata.
Usage: `get_field_info(model)` returns a `FieldInfo` instance.
"""
from collections import namedtuple
+from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.utils import six
from rest_framework.compat import OrderedDict
@@ -43,7 +44,11 @@ def _resolve_model(obj):
"""
if isinstance(obj, six.string_types) and len(obj.split('.')) == 2:
app_name, model_name = obj.split('.')
- return models.get_model(app_name, model_name)
+ resolved_model = models.get_model(app_name, model_name)
+ if resolved_model is None:
+ msg = "Django did not return a model for {0}.{1}"
+ raise ImproperlyConfigured(msg.format(app_name, model_name))
+ return resolved_model
elif inspect.isclass(obj) and issubclass(obj, models.Model):
return obj
raise ValueError("{0} is not a Django model".format(obj))