I have defined a User model and added a featured field to it:
class User(Document):
email = EmailField(required=True)
featured = BooleanField(default=False, required=True)
Then I create a user from this model and save it:
user = User(email=email, featured=False)
user.save()
But even having a default value and required flag I don’t see that field created in the db if the BooleanField is set to False. When I set it to True in model or when create the user, it creates it and saves proper True value to it.
I want this field to be always present on creation if it’s False or True.
What am I doing wrong?
What version are you running? We have a passing test case for this very issue:
See: https://github.com/MongoEngine/mongoengine/blob/master/tests/test_document.py#L2881-2893