Search code examples
commentsdocumentationmongoengine

description of the field in mongoengine


is there any way to add a description / hint to the field in the mongoengine model?

I have a situation when inline comments are entered before the line with the definition of the field, because it is not possible to explain the full meaning of this field only with name.


Solution

  • I'm not sure if that's really better but you can take advantage of the **kwargs of the Field constructor like this

    class FunkyDoc(Document):
        s = StringField(required=True, custom_doc="Lorem ipsum blablablablabla")
    

    Unknown parameters aren't taken into account so this won't interfer with MongoEngine internals