mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 20:10:10 +03:00
Halt on missing related models.
This commit is contained in:
parent
4ce42fb72b
commit
e72eee6f31
|
@ -50,7 +50,11 @@ def _resolve_model(obj):
|
||||||
"""
|
"""
|
||||||
if type(obj) == str and len(obj.split('.')) == 2:
|
if type(obj) == str 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