mirror of
https://github.com/django/django.git
synced 2025-10-03 23:34:47 +00:00
Fixed #24607 -- Serialized natural keys in multi-table inheritance models.
This commit is contained in:
parent
794f866cec
commit
74a575eb72
5 changed files with 68 additions and 3 deletions
|
@ -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):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue