mirror of
https://github.com/django/django.git
synced 2025-10-28 08:06:09 +00:00
Changed get_model to raise an exception on errors.
Returning None on errors required unpythonic error checking and was inconsistent with get_app_config. get_model was a private API until the previous commit, but given that it was certainly used in third party software, the change is explained in the release notes. Applied the same change to get_registered_model, which is a new private API introduced during the recent refactoring.
This commit is contained in:
@@ -192,11 +192,12 @@ class ModelState(object):
|
||||
meta_contents["unique_together"] = list(meta_contents["unique_together"])
|
||||
meta = type("Meta", tuple(), meta_contents)
|
||||
# Then, work out our bases
|
||||
bases = tuple(
|
||||
(apps.get_model(*base.split(".", 1)) if isinstance(base, six.string_types) else base)
|
||||
for base in self.bases
|
||||
)
|
||||
if None in bases:
|
||||
try:
|
||||
bases = tuple(
|
||||
(apps.get_model(*base.split(".", 1)) if isinstance(base, six.string_types) else base)
|
||||
for base in self.bases
|
||||
)
|
||||
except LookupError:
|
||||
raise InvalidBasesError("Cannot resolve one or more bases from %r" % (self.bases,))
|
||||
# Turn fields into a dict for the body, add other bits
|
||||
body = dict(self.fields)
|
||||
|
||||
Reference in New Issue
Block a user