From b085993901e57797bdf8944e86a8a2611ac1e823 Mon Sep 17 00:00:00 2001 From: "Brian J. Dowling" Date: Mon, 27 Jan 2014 23:05:29 +0000 Subject: [PATCH] Allow dynamic dictionary-style field access Allows the doc[key] syntax to work for dynamicembeddeddocument fields Fixes #559 --- mongoengine/base/document.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoengine/base/document.py b/mongoengine/base/document.py index f5eae8ff..c5ef087c 100644 --- a/mongoengine/base/document.py +++ b/mongoengine/base/document.py @@ -182,7 +182,7 @@ class BaseDocument(object): """Dictionary-style field access, set a field's value. """ # Ensure that the field exists before settings its value - if name not in self._fields: + if not self._dynamic and name not in self._fields: raise KeyError(name) return setattr(self, name, value)