Fields

The fields module contains a list of Field classes for model’s definition.

The example below shows the most common fields and builtin validations:

class Token(Model):
    key = StringField()
    secret = StringField()

class User(Model):
    login = StringField(required=True)
    name = StringField()
    role = StringField(choices=['admin', 'moderator', 'user'])
    email = EmailField(required=True)
    token = EmbeddedField(Token, required=True)
    is_active = BooleanField(default=False)
fields.Field[source]

This is the base class for all booby.fields. This class can also be used as field in any models.Model declaration.

Parameters:
  • default – This field default value.
  • required – If True this field value should not be None.
  • choices – A list of values where this field value should be in.
  • *validators – A list of field validators as positional arguments.
fields.StringField[source]

Field subclass with builtin string validation.

fields.IntegerField[source]

Field subclass with builtin integer validation.

fields.FloatField[source]

Field subclass with builtin float validation.

fields.BooleanField[source]

Field subclass with builtin bool validation.

fields.EmbeddedField[source]

Field subclass with builtin embedded models.Model validation.

fields.EmailField[source]

Field subclass with builtin email validation.

Project Versions

Previous topic

Models

Next topic

Validators

This Page