diff options
author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-01-26 12:57:08 +0100 |
---|---|---|
committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2014-01-26 13:08:05 +0100 |
commit | f901b4d6c869f4cfb4fc28a861c481f28e46bb3f (patch) | |
tree | da6526f8a137e3cb0200f58d88cc23243127fb1c /django/db/models/base.py | |
parent | 3c47786cb91617b3757e57b6bfeda06ef14e561a (diff) | |
download | django-f901b4d6c869f4cfb4fc28a861c481f28e46bb3f.tar.gz |
Took advantage of the new get_model API. Refs #21702.
Diffstat (limited to 'django/db/models/base.py')
-rw-r--r-- | django/db/models/base.py | 34 |
1 files changed, 16 insertions, 18 deletions
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 |