diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2009-03-15 03:41:33 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2009-03-15 03:41:33 +0000 |
| commit | 7d9b29a56ddc1a793a02d55743c372a8256b97aa (patch) | |
| tree | 1e92d02ddce69b58fc21439a4ca1a7e5c813730e /django/db/models/base.py | |
| parent | 957c721594deb9a6e91a83a7e1ff37502ec1bb97 (diff) | |
Use plain model.Manager, or suitable proxy, for model saving.
We can't use the default manager in Model.save_base(), since we need to
retrieve existing objects which might be filtered out by that manager. We now
always use a plain Manager instance at that point (or something that can
replace it, such as a GeoManager), making all existing rows in the
database visible to the saving code.
The logic for detecting a "suitable replacement" plain base is the same as for
related fields: if the use_for_related_fields is set on the manager subclass,
we can use it. The general requirement here is that we want a base class that
returns the appropriate QuerySet subclass, but does not restrict the rows
returned.
Fixed #8990, #9527.
Refs #2698 (which is not fixed by this change, but it's the first part of a
larger change to fix that bug.)
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10056 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/models/base.py')
| -rw-r--r-- | django/db/models/base.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py index 62ebbab7f0..dec0316947 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -69,6 +69,7 @@ class ModelBase(type): if getattr(new_class, '_default_manager', None): new_class._default_manager = None + new_class._base_manager = None # Bail out early if we have already created this class. m = get_model(new_class._meta.app_label, name, False) @@ -369,7 +370,7 @@ class Model(object): pk_val = self._get_pk_val(meta) pk_set = pk_val is not None record_exists = True - manager = cls._default_manager + manager = cls._base_manager if pk_set: # Determine whether a record with the primary key already exists. if (force_update or (not force_insert and |
