mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 20:40:14 +03:00
Merge e72eee6f31
into e85ef3b479
This commit is contained in:
commit
5f81a1c014
|
@ -51,7 +51,11 @@ def _resolve_model(obj):
|
||||||
"""
|
"""
|
||||||
if isinstance(obj, six.string_types) and len(obj.split('.')) == 2:
|
if isinstance(obj, six.string_types) and len(obj.split('.')) == 2:
|
||||||
app_name, model_name = obj.split('.')
|
app_name, model_name = obj.split('.')
|
||||||
return models.get_model(app_name, model_name)
|
model = models.get_model(app_name, model_name)
|
||||||
|
if model is None:
|
||||||
|
raise ValueError("{0} is not a Django model".format(obj))
|
||||||
|
else:
|
||||||
|
return model
|
||||||
elif inspect.isclass(obj) and issubclass(obj, models.Model):
|
elif inspect.isclass(obj) and issubclass(obj, models.Model):
|
||||||
return obj
|
return obj
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user