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
This commit is contained in:
Jacob Kaplan-Moss 2008-08-28 19:38:56 +00:00
parent 195420259a
commit 9f59fc5560
2 changed files with 5 additions and 1 deletions

View File

@ -84,7 +84,7 @@ def Deserializer(object_list, **options):
# Handle FK fields # Handle FK fields
elif field.rel and isinstance(field.rel, models.ManyToOneRel): 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) data[field.attname] = field.rel.to._meta.get_field(field.rel.field_name).to_python(field_value)
else: else:
data[field.attname] = None data[field.attname] = None

View File

@ -261,6 +261,10 @@ The end."""),
(fk_obj, 460, FKDataToO2O, 300), (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), (im2m_obj, 470, M2MIntermediateData, None),
#testing post- and prereferences and extra fields #testing post- and prereferences and extra fields