Skip to content

Fixed #12288 -- Validate that values in INSTALLED_APPS are unique #1626

Closed
wants to merge 3 commits into from

2 participants

@e0ne
e0ne commented Sep 13, 2013

No description provided.

@timgraham timgraham and 1 other commented on an outdated diff Sep 13, 2013
django/conf/__init__.py
@@ -109,7 +109,8 @@ def __setattr__(self, name, value):
"to a tuple, not a string.")
elif name == "INSTALLED_APPS":
value = list(value) # force evaluation of generators on Python 3
- if len(value) != len(set(value)):
+ apps = map(lambda s: s.split('.')[-1], value)
@timgraham
Django member
timgraham added a note Sep 13, 2013

could we use a list comprehension here instead? do we still need len(value) != len(set(value)) in the condition below?

@e0ne
e0ne added a note Sep 13, 2013

I don't understand your idea. But I found some redundant checks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@timgraham timgraham commented on an outdated diff Sep 13, 2013
django/conf/__init__.py
@@ -109,7 +109,8 @@ def __setattr__(self, name, value):
"to a tuple, not a string.")
elif name == "INSTALLED_APPS":
value = list(value) # force evaluation of generators on Python 3
- if len(value) != len(set(value)):
+ apps = map(lambda s: s.split('.')[-1], value)
+ if len(value) != len(set(value)) or len(value) != len(set(apps)):
raise ImproperlyConfigured("The INSTALLED_APPS setting must contain unique values.")
@timgraham
Django member
timgraham added a note Sep 13, 2013

could we change "values" to "app names" in the error message?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@timgraham timgraham commented on an outdated diff Sep 13, 2013
tests/settings_tests/tests.py
@@ -241,11 +241,14 @@ def tearDown(self):
def test_unique(self):
"""
An ImproperlyConfigured exception is raised if the INSTALLED_APPS contains
- any duplicate strings.
+ any duplicate appication name.
@timgraham
Django member
timgraham added a note Sep 13, 2013

name -> names

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@timgraham
Django member

merged in c1ec089 - thanks!

@timgraham timgraham closed this Sep 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.