diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-12-31 16:22:42 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-12-31 17:29:04 +0100 |
| commit | 5dfec4e23b4a3b81f8ec19bf0cf45147ad6b18e5 (patch) | |
| tree | 738f0a106dac0a6e73a472c1eea15d45b723306f /django/apps | |
| parent | 553500133cc4426f20407391f3493716357db45f (diff) | |
Checked unicity of app config names when populating the app registry.
This check will miss duplicates until the check for duplicate labels is
added.
Refs #21679.
Diffstat (limited to 'django/apps')
| -rw-r--r-- | django/apps/registry.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/django/apps/registry.py b/django/apps/registry.py index c7c9a05679..317bde33fe 100644 --- a/django/apps/registry.py +++ b/django/apps/registry.py @@ -1,4 +1,4 @@ -from collections import defaultdict, OrderedDict +from collections import Counter, defaultdict, OrderedDict import os import sys import warnings @@ -79,8 +79,19 @@ class Apps(object): app_config = entry else: app_config = AppConfig.create(entry) + # TODO: check for duplicate app labels here (#21679). self.app_configs[app_config.label] = app_config + # Check for duplicate app names. + counts = Counter( + app_config.name for app_config in self.app_configs.values()) + duplicates = [ + name for name, count in counts.most_common() if count > 1] + if duplicates: + raise ImproperlyConfigured( + "Application names aren't unique, " + "duplicates: %s" % ", ".join(duplicates)) + # Load models. for app_config in self.app_configs.values(): all_models = self.all_models[app_config.label] |
