Fixed #2894: XML deserializer now correctly handles null primary keys.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4046 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss 2006-11-07 05:01:35 +00:00
parent 86143f7599
commit a1199d8528
1 changed files with 5 additions and 1 deletions

View File

@ -166,6 +166,10 @@ class Deserializer(base.Deserializer):
# If it doesn't exist, set the field to None (which might trigger # If it doesn't exist, set the field to None (which might trigger
# validation error, but that's expected). # validation error, but that's expected).
RelatedModel = self._get_model_from_node(node, "to") RelatedModel = self._get_model_from_node(node, "to")
# Check if there is a child node named 'None', returning None if so.
if len(node.childNodes) == 1 and node.childNodes[0].nodeName == 'None':
return None
else:
return RelatedModel.objects.get(pk=getInnerText(node).strip().encode(self.encoding)) return RelatedModel.objects.get(pk=getInnerText(node).strip().encode(self.encoding))
def _handle_m2m_field_node(self, node): def _handle_m2m_field_node(self, node):