From 953123b3dc8460e62f7cffe2b5d62a5d554c2bae Mon Sep 17 00:00:00 2001 From: Stefan Wojcik Date: Sun, 11 Dec 2016 17:25:37 -0500 Subject: [PATCH] minor compat tweak --- mongoengine/base/document.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mongoengine/base/document.py b/mongoengine/base/document.py index 281ca703..03dc7562 100644 --- a/mongoengine/base/document.py +++ b/mongoengine/base/document.py @@ -675,10 +675,12 @@ class BaseDocument(object): if not only_fields: only_fields = [] - # get the class name from the document, falling back to the given + # Get the class name from the document, falling back to the given # class if unavailable class_name = son.get('_cls', cls._class_name) - data = {key: value for key, value in son.iteritems()} + + # Convert SON to a dict, making sure each key is a string + data = {str(key): value for key, value in son.iteritems()} # Return correct subclass for document type if class_name != cls._class_name: