diff --git a/TODO b/TODO index 0eac4a68fb..cb53fb88fd 100644 --- a/TODO +++ b/TODO @@ -10,7 +10,6 @@ Required for v1.2 * Resolve the public facing UI issues around using multi-db * Should we take the opportunity to modify DB backends to use fully qualified paths? * Should we clean up DATABASES['DATABASE_NAME'] to DATABASES['NAME'] etc? - * Meta.using? Is is still required/desirable? * Cleanup of new API entry points * validate() on a field * name/purpose clash with Honza? diff --git a/django/db/models/base.py b/django/db/models/base.py index 7a78ae5c7a..eb484ea3bc 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -438,7 +438,7 @@ class Model(object): need for overrides of save() to pass around internal-only parameters ('raw', 'cls', and 'origin'). """ - using = using or self._state.db or self._meta.using or DEFAULT_DB_ALIAS + using = using or self._state.db or DEFAULT_DB_ALIAS connection = connections[using] assert not (force_insert and force_update) if cls is None: @@ -591,7 +591,7 @@ class Model(object): parent_obj._collect_sub_objects(seen_objs) def delete(self, using=None): - using = using or self._state.db or self._meta.using or DEFAULT_DB_ALIAS + using = using or self._state.db or DEFAULT_DB_ALIAS connection = connections[using] assert self._get_pk_val() is not None, "%s object can't be deleted because its %s attribute is set to None." % (self._meta.object_name, self._meta.pk.attname) diff --git a/django/db/models/options.py b/django/db/models/options.py index c82da3a1cf..05ff54a333 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -21,7 +21,7 @@ get_verbose_name = lambda class_name: re.sub('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]| DEFAULT_NAMES = ('verbose_name', 'db_table', 'ordering', 'unique_together', 'permissions', 'get_latest_by', 'order_with_respect_to', 'app_label', 'db_tablespace', - 'abstract', 'managed', 'proxy', 'using', 'auto_created') + 'abstract', 'managed', 'proxy', 'auto_created') class Options(object): def __init__(self, meta, app_label=None): @@ -47,7 +47,6 @@ class Options(object): self.proxy_for_model = None self.parents = SortedDict() self.duplicate_targets = {} - self.using = None self.auto_created = False # To handle various inheritance situations, we need to track where diff --git a/django/db/models/query.py b/django/db/models/query.py index 05f98cc978..f1035837ef 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -25,20 +25,14 @@ class QuerySet(object): """ Represents a lazy database lookup for a set of objects. """ - def __init__(self, model=None, query=None): + def __init__(self, model=None, query=None, using=None): self.model = model # EmptyQuerySet instantiates QuerySet with model as None - if model: - using = model._meta.using - else: - using = None - using = using or DEFAULT_DB_ALIAS - connection = connections[using] + self.db = using or DEFAULT_DB_ALIAS self.query = query or sql.Query(self.model) self._result_cache = None self._iter = None self._sticky_filter = False - self.db = using ######################## # PYTHON MAGIC METHODS # diff --git a/docs/ref/models/options.txt b/docs/ref/models/options.txt index f7feb54e3a..f3e7363e36 100644 --- a/docs/ref/models/options.txt +++ b/docs/ref/models/options.txt @@ -4,8 +4,9 @@ Model ``Meta`` options ====================== -This document explains all the possible :ref:`metadata options ` that you can give your model in its internal -``class Meta``. +This document explains all the possible :ref:`metadata options +` that you can give your model in its internal ``class +Meta``. Available ``Meta`` options ========================== @@ -220,17 +221,6 @@ set of fields:: unique_together = ("driver", "restaurant") -``using`` ---------- - -.. attribute:: Options.using - -The alias for the default database to be used for this model. If this is not -provided the default is ``'default'``. If it is porvided it can be overidden -at the ``QuerySet`` level with the ``using()`` method. - -.. versionadded:: 1.2 - ``verbose_name`` ----------------