Duplicates apps in settings.INSTALLED_APPS
|Reported by:||trbs||Owned by:||nobody|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Duplicated in settings.INSTALLED_APPS are not removed automaticly.
As my project grows and the application lists grows with it, i tent to split of parts into a different python project
which i include in every django site i build. For the settings.py of the website it includes all the defaults from myproject.conf.settings
but this sometimes leads to duplicated in the INSTALLED_APPS list.
The duplicates are a human error and should not happen (or be avoided) but that doesn't mean it won't happen someday (specially with different developers working at the same site).
Attached to this ticket is a patch to check for duplicates while creating the django settings object in django.conf.init
I think that while developers should not put duplicates in there list, checking it while looping through DJANGO_SETTINGS_MODULE.INSTALLED_APPS and handling it explicitly is a good idea. (zen: Explicit is better then implicit)
The implementation currently uses a Set object, but could also be written with an
... if not app in new_installed_apps: new_installed_apps.append(app) ...
Would love to hear some comments on this :-)
As i think currently this is not checked/handled at all, the list just contains duplicate entries and that
could break some things, like registration in newformsadmin or databrowse.
Personally i believe it should check and either automaticly remove duplicates or raise some exception indicating
that duplicate values are not allowed.