Not sure, of course, if this is what you mean by an empty or not set ListField:
from mongoengine import * connect('tumblelog') class Post(Document): title = StringField(required=True) tags = ListField(StringField()) post1 = Post(title='Fun with MongoEngine', tags=['mongodb', 'mongoengine']) post1.save() for post in Post.objects: print post.title if not post.tags: print '-post has no tags' else: print post.tags
This will output:
Fun with MongoEngine [u'mongodb', u'mongoengine'] Fun with MongoEngine no tags -post has no tags
Gianfranco P.
source share