1
0
mirror of https://github.com/django/django.git synced 2024-12-24 01:55:49 +00:00
django/tests/serializers/models/multi_table.py
Denys Duchier cb7860cced Fixed #24607 -- Serialized natural keys in multi-table inheritance models.
Thanks João Paulo Melo de Sampaio for the test.
2018-02-12 21:15:04 -05:00

20 lines
436 B
Python

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)