diff options
| author | João Sampaio <jpmelos@gmail.com> | 2016-10-08 15:09:49 -0300 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-10-12 20:04:57 -0400 |
| commit | 74a575eb7296fb04e1fc2bd4e3f68dee3c66ee0a (patch) | |
| tree | dddf32453cd3d4f10c8d4c6bf64ab9fefcdeb4e7 /django/db/models/options.py | |
| parent | 794f866cecb7598c1537067cc1d932d95a86f439 (diff) | |
Fixed #24607 -- Serialized natural keys in multi-table inheritance models.
Diffstat (limited to 'django/db/models/options.py')
| -rw-r--r-- | django/db/models/options.py | 7 |
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): """ |
