Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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
@jacobian jacobian authored
View
2  django/core/serializers/python.py
@@ -84,7 +84,7 @@ def Deserializer(object_list, **options):
# Handle FK fields
elif field.rel and isinstance(field.rel, models.ManyToOneRel):
- if field_value:
+ if field_value is not None:
data[field.attname] = field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value)
else:
data[field.attname] = None
View
4 tests/regressiontests/serializers_regress/tests.py
@@ -261,6 +261,10 @@ def inherited_compare(testcase, pk, klass, data):
(fk_obj, 460, FKDataToO2O, 300),
+ # Regression test for #8651 -- FK = 0
+ (data_obj, 0, Anchor, "Anchor 0"),
+ (fk_obj, 465, FKData, 0),
+
(im2m_obj, 470, M2MIntermediateData, None),
#testing post- and prereferences and extra fields
Please sign in to comment.
Something went wrong with that request. Please try again.