Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit a1199d8528e2f51d333ea044a8b000665e2f7d7b 1 parent 86143f7
Jacob Kaplan-Moss authored November 07, 2006
6  django/core/serializers/xml_serializer.py
@@ -166,7 +166,11 @@ def _handle_fk_field_node(self, node):
166 166
         # If it doesn't exist, set the field to None (which might trigger 
167 167
         # validation error, but that's expected).
168 168
         RelatedModel = self._get_model_from_node(node, "to")
169  
-        return RelatedModel.objects.get(pk=getInnerText(node).strip().encode(self.encoding))
  169
+        # Check if there is a child node named 'None', returning None if so.
  170
+        if len(node.childNodes) == 1 and node.childNodes[0].nodeName == 'None':
  171
+            return None
  172
+        else:
  173
+            return RelatedModel.objects.get(pk=getInnerText(node).strip().encode(self.encoding))
170 174
         
171 175
     def _handle_m2m_field_node(self, node):
172 176
         """

0 notes on commit a1199d8

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