summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2017-02-11 06:40:15 -0500
committerTim Graham <timograham@gmail.com>2017-02-11 06:40:30 -0500
commiteeb28f47512c5ff969d014ba35b9e955de1583ce (patch)
treee09c15e3547eefb0c8a4ee38729cdc320544905a /django
parentad0b22d730f150fb95c6a0d4a78a9c7a694d380a (diff)
[1.11.x] Fixed #27742 -- Reverted "Fixed #24607 -- Serialized natural keys in multi-table inheritance models."
This reverts commit 74a575eb7296fb04e1fc2bd4e3f68dee3c66ee0a as it causes unexpected migrations and doesn't seem to be the best solution. Backport of 0595bca221825c0c6bd572a32f3bf9eff7069328 from master
Diffstat (limited to 'django')
-rw-r--r--django/core/serializers/base.py8
-rw-r--r--django/db/models/options.py7
2 files changed, 2 insertions, 13 deletions
diff --git a/django/core/serializers/base.py b/django/core/serializers/base.py
index 46fb25ea78..ae3866172b 100644
--- a/django/core/serializers/base.py
+++ b/django/core/serializers/base.py
@@ -88,7 +88,7 @@ class Serializer(object):
if self.selected_fields is None or field.attname in self.selected_fields:
self.handle_field(obj, field)
else:
- if self.field_is_selected(field) and self.output_pk_field(obj, field):
+ if self.selected_fields is None or field.attname[:-3] in self.selected_fields:
self.handle_fk_field(obj, field)
for field in concrete_model._meta.many_to_many:
if field.serialize:
@@ -101,12 +101,6 @@ class Serializer(object):
self.end_serialization()
return self.getvalue()
- def field_is_selected(self, field):
- return self.selected_fields is None or field.attname[:-3] in self.selected_fields
-
- def output_pk_field(self, obj, pk_field):
- return self.use_natural_primary_keys or pk_field != obj._meta.pk
-
def start_serialization(self):
"""
Called when serializing of the queryset starts.
diff --git a/django/db/models/options.py b/django/db/models/options.py
index 335289beea..1f1fb4bd75 100644
--- a/django/db/models/options.py
+++ b/django/db/models/options.py
@@ -13,7 +13,6 @@ from django.db import connections
from django.db.models import Manager
from django.db.models.fields import AutoField
from django.db.models.fields.proxy import OrderWrt
-from django.db.models.fields.related import OneToOneField
from django.db.models.query_utils import PathInfo
from django.utils import six
from django.utils.datastructures import ImmutableList, OrderedSet
@@ -298,11 +297,7 @@ class Options(object):
def setup_pk(self, field):
if not self.pk and field.primary_key:
self.pk = field
- # If the field is a OneToOneField and it's been marked as PK, then
- # this is a multi-table inheritance PK. It needs to be serialized
- # to relate the subclass instance to the superclass instance.
- if not isinstance(field, OneToOneField):
- field.serialize = False
+ field.serialize = False
def setup_proxy(self, target):
"""