aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/utils
diff options
context:
space:
mode:
authorTom Christie2014-11-28 15:36:04 +0000
committerTom Christie2014-11-28 15:36:04 +0000
commit3a5b3772fefc3c2f2c0899947cbc07bfe6e6b5d2 (patch)
tree62da2ff99cee21b83c3dd735b2d75fe08a4ef5e0 /rest_framework/utils
parent6fbd23ab346e1a5b5401ba83e2ad2cd3474d2410 (diff)
downloaddjango-rest-framework-3a5b3772fefc3c2f2c0899947cbc07bfe6e6b5d2.tar.bz2
Use ImproperlyConfigured when model meta lookup fails
Diffstat (limited to 'rest_framework/utils')
-rw-r--r--rest_framework/utils/model_meta.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/rest_framework/utils/model_meta.py b/rest_framework/utils/model_meta.py
index 54f9310d..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
@@ -44,9 +45,9 @@ def _resolve_model(obj):
if isinstance(obj, six.string_types) and len(obj.split('.')) == 2:
app_name, model_name = obj.split('.')
resolved_model = models.get_model(app_name, model_name)
- if not resolved_model:
- raise ValueError("Django did not return a model for "
- "{0}.{1}".format(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