diff options
Diffstat (limited to 'django/db')
-rw-r--r-- | django/db/migrations/state.py | 2 | ||||
-rw-r--r-- | django/db/models/base.py | 34 |
2 files changed, 17 insertions, 19 deletions
diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py index ab4c4be2f7..f802b6cc0b 100644 --- a/django/db/migrations/state.py +++ b/django/db/migrations/state.py @@ -194,7 +194,7 @@ class ModelState(object): # Then, work out our bases try: bases = tuple( - (apps.get_model(*base.split(".", 1)) if isinstance(base, six.string_types) else base) + (apps.get_model(base) if isinstance(base, six.string_types) else base) for base in self.bases ) except LookupError: diff --git a/django/db/models/base.py b/django/db/models/base.py index 9e835d0e16..65e1f5d9e4 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -1054,7 +1054,7 @@ class Model(six.with_metaclass(ModelBase)): errors = [] if cls._meta.swapped: try: - app_label, model_name = cls._meta.swapped.split('.') + apps.get_model(cls._meta.swapped) except ValueError: errors.append( checks.Error( @@ -1064,24 +1064,22 @@ class Model(six.with_metaclass(ModelBase)): id='E002', ) ) - else: - try: - apps.get_model(app_label, model_name) - except LookupError: - errors.append( - checks.Error( - ('The model has been swapped out for %s.%s ' - 'which has not been installed or is abstract.') % ( - app_label, model_name - ), - hint=('Ensure that you did not misspell the model ' - 'name and the app name as well as the model ' - 'is not abstract. Does your INSTALLED_APPS ' - 'setting contain the "%s" app?') % app_label, - obj=cls, - id='E003', - ) + except LookupError: + app_label, model_name = cls._meta.swapped.split('.') + errors.append( + checks.Error( + ('The model has been swapped out for %s.%s ' + 'which has not been installed or is abstract.') % ( + app_label, model_name + ), + hint=('Ensure that you did not misspell the model ' + 'name and the app name as well as the model ' + 'is not abstract. Does your INSTALLED_APPS ' + 'setting contain the "%s" app?') % app_label, + obj=cls, + id='E003', ) + ) return errors @classmethod |