I am not sure if it is a bug within MongoEngine or if I miss something. I have the following Models set up:
class Features(EmbeddedDocument):
version = FloatField()
data = ListField(StringField)
class Article(Document):
vendor = ReferenceField(Vendor)
url = URLField()
author = StringField()
clean_content = StringField()
features = EmbeddedDocumentField(Features)
When I test my models like this:
#add vendor
vendor = Vendor(name="techcrunch", config="vendor config")
vendor.save()
#create features
features = Features(version = 1.0)
features.data = ["5", "89"]
#add article
article = Article(vendor = vendor, url ="http://www.techcrunch.com",
author ="MG Siegler", clean_content = "Apple rocks!")
article.features = features
article.save()
I get the following error:
TypeError: unbound method _validate() must be called with StringField instance as first argument (got str instance instead)
Can someone explain that?
EDIT:
Nevermind. I found my error.
It has to be:
class Features(EmbeddedDocument):
version = FloatField()
data = ListField(StringField())
I found the error.
It has to be:
class Features(EmbeddedDocument):
version = FloatField()
data = ListField(StringField())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With