summaryrefslogtreecommitdiff
path: root/django/db/models
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/models')
-rw-r--r--django/db/models/options.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/django/db/models/options.py b/django/db/models/options.py
index 0cf1726315..04696a4e9e 100644
--- a/django/db/models/options.py
+++ b/django/db/models/options.py
@@ -13,6 +13,7 @@ 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.utils import six
from django.utils.datastructures import ImmutableList, OrderedSet
from django.utils.deprecation import (
@@ -296,7 +297,11 @@ class Options(object):
def setup_pk(self, field):
if not self.pk and field.primary_key:
self.pk = field
- field.serialize = False
+ # 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
def setup_proxy(self, target):
"""