I have defined a document type in monoengine as follows:
from mongoengine import *
import datetime
class User(Document):
username = StringField(min_length = 1, max_length = 20, regex = '(\w+)', required = True, unique = True)
password = StringField(min_length = 5, required = True)
email = EmailField(required = True, unique = True)
name = StringField(min_length = 3, max_length = 40, required = True)
date_created = DateTimeField(default = datetime.datetime.utcnow, required = True)
However, when there is an error, the field name is the member variable. For some fields, this will look quite ugly for the user. For example, “date_created” should really say “Date Created”.
So, I am trying to find a way to tell Mongoengine to use a “nicer” name instead of the member variable name but I can’t seem to find a way. I’ve tried name and verbose_name but they don’t appear to do anything and I’ve looked though the docs, so any help would be appreciated.
verbose_nameis used for outputting to a frontend user and its up to you to output the verbose_name instead of the field name when rendering – eg in a form.