1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #24607 -- Serialized natural keys in multi-table inheritance models.

Thanks João Paulo Melo de Sampaio for the test.
This commit is contained in:
Denys Duchier
2017-02-11 06:40:15 -05:00
committed by Tim Graham
parent 9ba3df8240
commit cb7860cced
4 changed files with 57 additions and 2 deletions

View File

@@ -0,0 +1,19 @@
from django.db import models
class ParentManager(models.Manager):
def get_by_natural_key(self, parent_data):
return self.get(parent_data=parent_data)
class Parent(models.Model):
parent_data = models.CharField(max_length=30, unique=True)
objects = ParentManager()
def natural_key(self):
return (self.parent_data,)
class Child(Parent):
child_data = models.CharField(max_length=30, unique=True)