How do I add an attribute to all documents in collection using mongoengine? I've tried several ways:
for d in MyDocuments.objects:
d.attr = 'test'
d.save()
This doesn't give any errors but it doesn't add new attribute to document.
I've also tried
MyDocuments.objects.all().update(set__attr='test')
This gives InvalidQueryError: Cannot resolve field "attr"
The same error happens when I try
for d in MyDocuments.objects:
d.update(set__attr='test')
Specifically I'm trying to add _cls
attribute because I enabled inheritance and I already have some objects in database that don't have that attribute.