|
@@ -260,10 +260,11 @@ def feature_hidden(feature_name):
|
260
|
260
|
|
261
|
261
|
|
262
|
262
|
# The following section is concerned with offering both the
|
263
|
|
-# get_model(app_label, model_name) and is_model_registered(app_label, model_name)
|
264
|
|
-# methods. Because the Django internals dramatically changed in the Django 1.7
|
265
|
|
-# app refactor, we distinguish based on the Django version and declare
|
266
|
|
-# a total of four methods that hopefully do mostly the same
|
|
263
|
+# get_model(app_label, model_name) and
|
|
264
|
+# is_model_registered(app_label, model_name) methods. Because the Django
|
|
265
|
+# internals dramatically changed in the Django 1.7 app refactor, we distinguish
|
|
266
|
+# based on the Django version and declare a total of four methods that
|
|
267
|
+# hopefully do mostly the same
|
267
|
268
|
|
268
|
269
|
|
269
|
270
|
if django.VERSION < (1, 7):
|
|
@@ -275,10 +276,11 @@ if django.VERSION < (1, 7):
|
275
|
276
|
Gets a model class by it's app label and model name. Fails loudly if
|
276
|
277
|
the model class can't be imported.
|
277
|
278
|
This is merely a thin wrapper around Django's get_model function.
|
|
279
|
+ Raises LookupError if model isn't found.
|
278
|
280
|
"""
|
279
|
281
|
model = django_get_model(app_label, model_name, *args, **kwargs)
|
280
|
282
|
if model is None:
|
281
|
|
- raise ImportError(
|
|
283
|
+ raise LookupError(
|
282
|
284
|
"{app_label}.{model_name} could not be imported.".format(
|
283
|
285
|
app_label=app_label, model_name=model_name))
|
284
|
286
|
return model
|
|
@@ -302,6 +304,7 @@ else:
|
302
|
304
|
which makes it safe to call when the registry is being populated.
|
303
|
305
|
All other methods to access models might raise an exception about the
|
304
|
306
|
registry not being ready yet.
|
|
307
|
+ Raises LookupError if model isn't found.
|
305
|
308
|
"""
|
306
|
309
|
return apps.get_registered_model(app_label, model_name)
|
307
|
310
|
|