1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #4288 -- Modified serializers to pay attention to the to_field attribute on ForeignKeys. Thanks to Sandro Dentella for the report and the helpful test case.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5232 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee
2007-05-14 14:14:49 +00:00
parent f15036ae6d
commit c38a93e4d9
5 changed files with 34 additions and 12 deletions

View File

@@ -116,6 +116,16 @@ class FKSelfData(models.Model):
class M2MSelfData(models.Model):
data = models.ManyToManyField('self', null=True, symmetrical=False)
class UniqueAnchor(models.Model):
"""This is a model that can be used as
something for other models to point at"""
data = models.CharField(unique=True, maxlength=30)
class FKDataToField(models.Model):
data = models.ForeignKey(UniqueAnchor, null=True, to_field='data')
# The following test classes are for validating the
# deserialization of objects that use a user-defined
# field as the primary key.