diff --git a/django/core/management/commands/dumpdata.py b/django/core/management/commands/dumpdata.py index d795d6f8b8..215e58605e 100644 --- a/django/core/management/commands/dumpdata.py +++ b/django/core/management/commands/dumpdata.py @@ -31,10 +31,10 @@ class Command(BaseCommand): exclude = options.get('exclude',[]) show_traceback = options.get('traceback', False) - excluded_apps = [get_app(app_label) for app_label in exclude] + excluded_apps = set(get_app(app_label) for app_label in exclude) if len(app_labels) == 0: - app_list = SortedDict([(app, None) for app in get_apps() if app not in excluded_apps]) + app_list = SortedDict((app, None) for app in get_apps() if app not in excluded_apps) else: app_list = SortedDict() for label in app_labels: diff --git a/django/core/management/commands/syncdb.py b/django/core/management/commands/syncdb.py index 85c1c1f4b7..31c1cb3121 100644 --- a/django/core/management/commands/syncdb.py +++ b/django/core/management/commands/syncdb.py @@ -59,11 +59,11 @@ class Command(NoArgsCommand): created_models = set() pending_references = {} - excluded_apps = [models.get_app(app_label) for app_label in exclude] - app_list = [app for app in models.get_apps() if app not in excluded_apps] + excluded_apps = set(models.get_app(app_label) for app_label in exclude) + included_apps = set(app for app in models.get_apps() if app not in excluded_apps) # Create the tables for each model - for app in app_list: + for app in included_apps: app_name = app.__name__.split('.')[-2] model_list = models.get_models(app, include_auto_created=True) for model in model_list: @@ -101,7 +101,7 @@ class Command(NoArgsCommand): # Install custom SQL for the app (but only if this # is a model we've just created) - for app in app_list: + for app in included_apps: app_name = app.__name__.split('.')[-2] for model in models.get_models(app): if model in created_models: @@ -126,7 +126,7 @@ class Command(NoArgsCommand): print "No custom SQL for %s.%s model" % (app_name, model._meta.object_name) # Install SQL indicies for all newly created models - for app in app_list: + for app in included_apps: app_name = app.__name__.split('.')[-2] for model in models.get_models(app): if model in created_models: diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py index 24caf67c14..966ab0354e 100644 --- a/django/db/backends/__init__.py +++ b/django/db/backends/__init__.py @@ -16,6 +16,7 @@ except ImportError: # Python 2.3 fallback from django.utils import _decimal as decimal +from django.db import DEFAULT_DB_ALIAS from django.db.backends import util from django.utils import datetime_safe from django.utils.importlib import import_module @@ -26,7 +27,7 @@ class BaseDatabaseWrapper(local): """ ops = None - def __init__(self, settings_dict, alias='default'): + def __init__(self, settings_dict, alias=DEFAULT_DB_ALIAS): # `settings_dict` should be a dictionary containing keys such as # DATABASE_NAME, DATABASE_USER, etc. It's called `settings_dict` # instead of `settings` to disambiguate it from Django settings