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 = String()
    secret = String()

class User(Model):
    login = String(required=True)
    name = String()
    role = String(choices=['admin', 'moderator', 'user'])
    email = Email(required=True)
    token = Embedded(Token, required=True)
    is_active = Boolean(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‘s value.

    If passed a callable object then uses its return value as the field’s default. This is particularly useful when working with mutable objects.

    If default is a callable it can optionaly receive the owner model instance as its first positional argument.

  • 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.String[source]

Field subclass with builtin string validation.

fields.Integer[source]

Field subclass with builtin integer validation.

fields.Float[source]

Field subclass with builtin float validation.

fields.Boolean[source]

Field subclass with builtin bool validation.

fields.Embedded[source]

Field subclass with builtin embedded models.Model validation.

fields.Email[source]

Field subclass with builtin email validation.

Read the Docs v: 0.5.0
Versions
latest
0.5.0
0.4.0
0.3.0
0.2.3
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.