Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #8651: correctly deserialize objects with 0 for pk/fk.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8676 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 9f59fc5560ae4ae1d6b73996393caae2314fd414 1 parent 1954202
Jacob Kaplan-Moss authored August 28, 2008
2  django/core/serializers/python.py
@@ -84,7 +84,7 @@ def Deserializer(object_list, **options):
84 84
 
85 85
             # Handle FK fields
86 86
             elif field.rel and isinstance(field.rel, models.ManyToOneRel):
87  
-                if field_value:
  87
+                if field_value is not None:
88 88
                     data[field.attname] = field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value)
89 89
                 else:
90 90
                     data[field.attname] = None
4  tests/regressiontests/serializers_regress/tests.py
@@ -261,6 +261,10 @@ def inherited_compare(testcase, pk, klass, data):
261 261
 
262 262
     (fk_obj, 460, FKDataToO2O, 300),
263 263
     
  264
+    # Regression test for #8651 -- FK = 0
  265
+    (data_obj, 0, Anchor, "Anchor 0"),
  266
+    (fk_obj, 465, FKData, 0),
  267
+    
264 268
     (im2m_obj, 470, M2MIntermediateData, None),
265 269
     
266 270
     #testing post- and prereferences and extra fields

0 notes on commit 9f59fc5

Please sign in to comment.
Something went wrong with that request. Please try again.