mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[1.9.x] Separated natural key serialization tests
Backport of d59d3caf3 from master.
This commit is contained in:
@@ -157,3 +157,24 @@ class Player(models.Model):
|
||||
|
||||
def __str__(self):
|
||||
return '%s (%d) playing for %s' % (self.name, self.rank, self.team.to_string())
|
||||
|
||||
|
||||
# ******** Models for test_natural.py ***********
|
||||
|
||||
class NaturalKeyAnchorManager(models.Manager):
|
||||
def get_by_natural_key(self, data):
|
||||
return self.get(data=data)
|
||||
|
||||
|
||||
class NaturalKeyAnchor(models.Model):
|
||||
objects = NaturalKeyAnchorManager()
|
||||
|
||||
data = models.CharField(max_length=100, unique=True)
|
||||
title = models.CharField(max_length=100, null=True)
|
||||
|
||||
def natural_key(self):
|
||||
return (self.data,)
|
||||
|
||||
|
||||
class FKDataNaturalKey(models.Model):
|
||||
data = models.ForeignKey(NaturalKeyAnchor, models.SET_NULL, null=True)
|
||||
|
||||
Reference in New Issue
Block a user