summaryrefslogtreecommitdiff
path: root/django/core/serializers/python.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2010-03-18 15:22:15 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2010-03-18 15:22:15 +0000
commit10de2a837f580d76a480a9e0b974cecd2d1d26cb (patch)
tree7c510c636247de1a7084bf17ae87f7bf76a9c4f9 /django/core/serializers/python.py
parentbe8a1f612dde1bff3dcdab05c3a916f27946dd31 (diff)
Fixed #13030 -- Corrected natural key deserialization to subclasses. Thanks to yishaibeeri for the report and test case.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12804 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/core/serializers/python.py')
-rw-r--r--django/core/serializers/python.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/django/core/serializers/python.py b/django/core/serializers/python.py
index 3defb6aa27..a68ea21f78 100644
--- a/django/core/serializers/python.py
+++ b/django/core/serializers/python.py
@@ -111,6 +111,10 @@ def Deserializer(object_list, **options):
if hasattr(field_value, '__iter__'):
obj = field.rel.to._default_manager.db_manager(db).get_by_natural_key(*field_value)
value = getattr(obj, field.rel.field_name)
+ # If this is a natural foreign key to an object that
+ # has a FK/O2O as the foreign key, use the FK value
+ if field.rel.to._meta.pk.rel:
+ value = value.pk
else:
value = field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value)
data[field.attname] = value