mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +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:
committed by
Tim Graham
parent
9ba3df8240
commit
cb7860cced
19
tests/serializers/models/multi_table.py
Normal file
19
tests/serializers/models/multi_table.py
Normal 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)
|
||||
Reference in New Issue
Block a user