Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

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

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 86143f7 commit a1199d8528e2f51d333ea044a8b000665e2f7d7b @jacobian jacobian committed
Showing with 5 additions and 1 deletion.
  1. +5 −1 django/core/serializers/
6 django/core/serializers/
@@ -166,7 +166,11 @@ def _handle_fk_field_node(self, node):
# If it doesn't exist, set the field to None (which might trigger
# validation error, but that's expected).
RelatedModel = self._get_model_from_node(node, "to")
- return RelatedModel.objects.get(pk=getInnerText(node).strip().encode(self.encoding))
+ # 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))
def _handle_m2m_field_node(self, node):

0 comments on commit a1199d8

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