diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/serializers/base.py | 2 | ||||
| -rw-r--r-- | django/db/models/base.py | 13 | ||||
| -rw-r--r-- | django/db/models/options.py | 2 |
3 files changed, 11 insertions, 6 deletions
diff --git a/django/core/serializers/base.py b/django/core/serializers/base.py index a79497ecec..e22a35815b 100644 --- a/django/core/serializers/base.py +++ b/django/core/serializers/base.py @@ -38,7 +38,7 @@ class Serializer(object): self.start_serialization() for obj in queryset: self.start_object(obj) - for field in obj._meta.fields: + for field in obj._meta.local_fields: if field.serialize: if field.rel is None: if self.selected_fields is None or field.attname in self.selected_fields: diff --git a/django/db/models/base.py b/django/db/models/base.py index 0ee225675a..5dd11a9d83 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -290,12 +290,17 @@ class Model(object): meta = cls._meta signal = False - for parent, field in meta.parents.items(): - self.save_base(raw, parent) - setattr(self, field.attname, self._get_pk_val(parent._meta)) + # If we are in a raw save, save the object exactly as presented. + # That means that we don't try to be smart about saving attributes + # that might have come from the parent class - we just save the + # attributes we have been given to the class we have been given. + if not raw: + for parent, field in meta.parents.items(): + self.save_base(raw, parent) + setattr(self, field.attname, self._get_pk_val(parent._meta)) non_pks = [f for f in meta.local_fields if not f.primary_key] - + # First, try an UPDATE. If that doesn't update anything, do an INSERT. pk_val = self._get_pk_val(meta) # Note: the comparison with '' is required for compatibility with diff --git a/django/db/models/options.py b/django/db/models/options.py index 4036bfb36e..bc1aec62c1 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -102,7 +102,7 @@ class Options(object): # field. field = self.parents.value_for_index(0) field.primary_key = True - self.pk = field + self.setup_pk(field) else: auto = AutoField(verbose_name='ID', primary_key=True, auto_created=True) |
