Python wtforms.StringField() Examples

The following are 2 code examples of wtforms.StringField(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wtforms , or try the search function .
Example #1
Source File: views.py    From buku with GNU General Public License v3.0 5 votes vote down vote up
def scaffold_form(self):
        class CustomForm(FlaskForm):  # pylint: disable=too-few-public-methods
            name = wtforms.StringField(validators=[wtforms.validators.DataRequired()])

        return CustomForm 
Example #2
Source File: forms.py    From sample-platform with ISC License 5 votes vote down vote up
def unique_username(form, field) -> None:
    """
    Check if a user already exists with this name.

    :param form: The form which is being passed in
    :type form: Form
    :param field: The data value for the 'name' inserted by new User
    :type field : StringField
    """
    user = User.query.filter(User.name == field.data).first()
    if user is not None:
        raise ValidationError('There is already a user with this name')