Author: jacob
Date: 2008-08-28 14:38:56 -0500 (Thu, 28 Aug 2008)
New Revision: 8676
Modified:
django/trunk/django/core/serializers/python.py
django/trunk/tests/regressiontests/serializers_regress/tests.py
Log:
Fixed #8651: correctly deserialize objects with 0 for pk/fk.
Modified: django/trunk/django/core/serializers/python.py
===================================================================
--- django/trunk/django/core/serializers/python.py 2008-08-28 19:28:45 UTC
(rev 8675)
+++ django/trunk/django/core/serializers/python.py 2008-08-28 19:38:56 UTC
(rev 8676)
@@ -84,7 +84,7 @@
# 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
Modified: django/trunk/tests/regressiontests/serializers_regress/tests.py
===================================================================
--- django/trunk/tests/regressiontests/serializers_regress/tests.py
2008-08-28 19:28:45 UTC (rev 8675)
+++ django/trunk/tests/regressiontests/serializers_regress/tests.py
2008-08-28 19:38:56 UTC (rev 8676)
@@ -261,6 +261,10 @@
(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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---