InvalidDocument: Cannot encode object: <User: User object> ReferenceField with MongoEngine
问题 I've been working with Flask and MongoEngine, and I am having trouble when trying to save an object because of a ReferenceField. This is what my model looks like: class User(UserMixin, db.Document): first_name = db.StringField(max_length=255, required=True) last_name = db.StringField(max_length=255, required=True) email = db.StringField(max_length=255) class Post(db.Document): description = db.StringField(max_length=255, required=True) inserted_at = db.DateTimeField(default=datetime.datetime