Data Fields

We extends the field classes from peewee with two properties (dt_orderable and dt_searchable) and two conversion methods (dt_order() and dt_search()) for the integration with DataTables server-side processing.

class flask_datatables.fields.Field(orderable=None, searchable=None, null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]

Bases: Field

Extending peewee.Field.

Parameters:
  • orderable (Union[bool, Field, None]) – Optional[Union[bool, peewee.Field]]: DataTables orderable field.

  • searchable (Union[bool, Field, None]) – Optional[Union[bool, peewee.Field]]: DataTables searchable field.

  • **kwargs – Arbitrary arguments accepted by peewee.Field.

  • null (bool) –

  • index (bool) –

  • unique (bool) –

  • column_name (Optional[str]) –

  • default (Any) –

  • primary_key (bool) –

  • constraints (Optional[List[SQL]]) –

  • sequence (Optional[str]) –

  • collation (Optional[str]) –

  • unindexed (bool) –

  • choices (Optional[Iterable[Tuple[str, Any]]]) –

  • help_text (Optional[str]) –

  • verbose_name (Optional[str]) –

  • index_type (Optional[str]) –

  • db_column (Optional[str]) –

  • _hidden (bool) –

If orderable and/or searchable is a bool value, it indicates if the field supports DataTables ordering and/or searching:

  • True means the field is orderable and/or searchable, and it will refer to its properties dt_orderable and/or dt_searchable as its default field instance;

    Note

    If the property returns None, then the field is orderable and/or searchable by itself with its own values.

  • False disables ordering and searching on the field;

  • an instance of peewee.Field indicates that the current field is orderable and/or searchable through the given field instance.

Important

If orderable and/or searchable is an instance of peewee.Field, then its attributes orderable and/or searchable will be the corresponding instance.

If orderable and/or searchable is True, then it refers to its properties dt_orderable and/or dt_searchable as the actual value:

  • if the properties return an instance of peewee.Field, then the attributes will be the returned instance; i.e. the field is orderable and/or searchable by converting to the target field instead of itself;

  • if the properties return None, then the attributes will be True; i.e. the field is orderable and/or searchable by itself with its value.

If orderable and/or searchable is False, then the attributes will be False as well.

static dt_order(value)[source]

Convert value for DataTables ordering operation.

Parameters:

value (Any) – Source value.

Return type:

Any

Returns:

Converted value.

Convert value for DataTables searching operation.

Parameters:

value (Any) – Source value.

Return type:

Any

Returns:

Converted value.

property dt_orderable: Field | None

DataTables default orderable field.

property dt_searchable: Field | None

DataTables default searchable field.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.AutoField(*args, **kwargs)[source]

Bases: AutoField, IntegerField

Extending peewee.AutoField.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.BareField(adapt=None, *args, **kwargs)[source]

Bases: BareField, Field

Extending peewee.BareField.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.BigAutoField(*args, **kwargs)[source]

Bases: BigAutoField, AutoField

Extending peewee.BigAutoField.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.BigBitField(*args, **kwargs)[source]

Bases: BigBitField, BlobField

Extending peewee.BigBitField.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.BigIntegerField(orderable=None, searchable=None, null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]

Bases: BigIntegerField, IntegerField

Extending peewee.BigIntegerField.

Parameters:
  • orderable (bool | Field) –

  • searchable (bool | Field) –

  • null (bool) –

  • index (bool) –

  • unique (bool) –

  • column_name (Optional[str]) –

  • default (Any) –

  • primary_key (bool) –

  • constraints (Optional[List[SQL]]) –

  • sequence (Optional[str]) –

  • collation (Optional[str]) –

  • unindexed (bool) –

  • choices (Optional[Iterable[Tuple[str, Any]]]) –

  • help_text (Optional[str]) –

  • verbose_name (Optional[str]) –

  • index_type (Optional[str]) –

  • db_column (Optional[str]) –

  • _hidden (bool) –

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.BinaryUUIDField(orderable=None, searchable=None, null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]

Bases: BinaryUUIDField, Field

Extending peewee.BinaryUUIDField.

Parameters:
  • orderable (bool | Field) –

  • searchable (bool | Field) –

  • null (bool) –

  • index (bool) –

  • unique (bool) –

  • column_name (Optional[str]) –

  • default (Any) –

  • primary_key (bool) –

  • constraints (Optional[List[SQL]]) –

  • sequence (Optional[str]) –

  • collation (Optional[str]) –

  • unindexed (bool) –

  • choices (Optional[Iterable[Tuple[str, Any]]]) –

  • help_text (Optional[str]) –

  • verbose_name (Optional[str]) –

  • index_type (Optional[str]) –

  • db_column (Optional[str]) –

  • _hidden (bool) –

Convert value for DataTables searching operation.

Parameters:

value (UUID) – Source value.

Return type:

str

Returns:

Converted value.

property dt_searchable: Field | None

DataTables default searchable field.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.BitField(*args, **kwargs)[source]

Bases: BitField, BigIntegerField

Extending peewee.BitField.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.BlobField(orderable=None, searchable=None, null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]

Bases: BlobField, Field

Extending peewee.BlobField.

Parameters:
  • orderable (bool | Field) –

  • searchable (bool | Field) –

  • null (bool) –

  • index (bool) –

  • unique (bool) –

  • column_name (Optional[str]) –

  • default (Any) –

  • primary_key (bool) –

  • constraints (Optional[List[SQL]]) –

  • sequence (Optional[str]) –

  • collation (Optional[str]) –

  • unindexed (bool) –

  • choices (Optional[Iterable[Tuple[str, Any]]]) –

  • help_text (Optional[str]) –

  • verbose_name (Optional[str]) –

  • index_type (Optional[str]) –

  • db_column (Optional[str]) –

  • _hidden (bool) –

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.BooleanField(orderable=None, searchable=None, null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]

Bases: BooleanField, Field

Extending peewee.BooleanField.

Parameters:
  • orderable (bool | Field) –

  • searchable (bool | Field) –

  • null (bool) –

  • index (bool) –

  • unique (bool) –

  • column_name (Optional[str]) –

  • default (Any) –

  • primary_key (bool) –

  • constraints (Optional[List[SQL]]) –

  • sequence (Optional[str]) –

  • collation (Optional[str]) –

  • unindexed (bool) –

  • choices (Optional[Iterable[Tuple[str, Any]]]) –

  • help_text (Optional[str]) –

  • verbose_name (Optional[str]) –

  • index_type (Optional[str]) –

  • db_column (Optional[str]) –

  • _hidden (bool) –

Convert value for DataTables searching operation.

Parameters:

value (bool) – Source value.

Return type:

str

Returns:

Converted value.

property dt_searchable: Field | None

DataTables default searchable field.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.CharField(max_length=255, *args, **kwargs)[source]

Bases: CharField, _StringField

Extending peewee.CharField.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.DateField(formats=None, *args, **kwargs)[source]

Bases: DateField, _BaseFormattedField

Extending peewee.DateField.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.DateTimeField(formats=None, *args, **kwargs)[source]

Bases: DateTimeField, _BaseFormattedField

Extending peewee.DateTimeField.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.DecimalField(max_digits=10, decimal_places=5, auto_round=False, rounding=None, *args, **kwargs)[source]

Bases: DecimalField, Field

Extending peewee.DecimalField.

Convert value for DataTables searching operation.

Parameters:

value (Decimal) – Source value.

Return type:

str

Returns:

Converted value.

property dt_searchable: Field | None

DataTables default searchable field.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.DoubleField(orderable=None, searchable=None, null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]

Bases: DoubleField, FloatField

Extending peewee.DoubleField.

Parameters:
  • orderable (bool | Field) –

  • searchable (bool | Field) –

  • null (bool) –

  • index (bool) –

  • unique (bool) –

  • column_name (Optional[str]) –

  • default (Any) –

  • primary_key (bool) –

  • constraints (Optional[List[SQL]]) –

  • sequence (Optional[str]) –

  • collation (Optional[str]) –

  • unindexed (bool) –

  • choices (Optional[Iterable[Tuple[str, Any]]]) –

  • help_text (Optional[str]) –

  • verbose_name (Optional[str]) –

  • index_type (Optional[str]) –

  • db_column (Optional[str]) –

  • _hidden (bool) –

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.FixedCharField(max_length=255, *args, **kwargs)[source]

Bases: FixedCharField, CharField

Extending peewee.FixedCharField.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.FloatField(orderable=None, searchable=None, null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]

Bases: FloatField, Field

Extending peewee.FloatField.

Parameters:
  • orderable (bool | Field) –

  • searchable (bool | Field) –

  • null (bool) –

  • index (bool) –

  • unique (bool) –

  • column_name (Optional[str]) –

  • default (Any) –

  • primary_key (bool) –

  • constraints (Optional[List[SQL]]) –

  • sequence (Optional[str]) –

  • collation (Optional[str]) –

  • unindexed (bool) –

  • choices (Optional[Iterable[Tuple[str, Any]]]) –

  • help_text (Optional[str]) –

  • verbose_name (Optional[str]) –

  • index_type (Optional[str]) –

  • db_column (Optional[str]) –

  • _hidden (bool) –

Convert value for DataTables searching operation.

Parameters:

value (float) – Source value.

Return type:

str

Returns:

Converted value.

property dt_searchable: Field | None

DataTables default searchable field.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.ForeignKeyField(model, field=None, backref=None, on_delete=None, on_update=None, deferrable=None, _deferred=None, rel_model=None, to_field=None, object_id_name=None, lazy_load=True, constraint_name=None, related_name=None, *args, **kwargs)[source]

Bases: ForeignKeyField, Field

Extending peewee.ForeignKeyField.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.IdentityField(generate_always=False, **kwargs)[source]

Bases: IdentityField, AutoField

Extending peewee.IdentityField.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.IntegerField(orderable=None, searchable=None, null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]

Bases: IntegerField, Field

Extending peewee.IntegerField.

Parameters:
  • orderable (bool | Field) –

  • searchable (bool | Field) –

  • null (bool) –

  • index (bool) –

  • unique (bool) –

  • column_name (Optional[str]) –

  • default (Any) –

  • primary_key (bool) –

  • constraints (Optional[List[SQL]]) –

  • sequence (Optional[str]) –

  • collation (Optional[str]) –

  • unindexed (bool) –

  • choices (Optional[Iterable[Tuple[str, Any]]]) –

  • help_text (Optional[str]) –

  • verbose_name (Optional[str]) –

  • index_type (Optional[str]) –

  • db_column (Optional[str]) –

  • _hidden (bool) –

Convert value for DataTables searching operation.

Parameters:

value (int) – Source value.

Return type:

str

Returns:

Converted value.

property dt_searchable: Field | None

DataTables default searchable field.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.IPField(orderable=None, searchable=None, null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]

Bases: IPField, BigIntegerField

Extending peewee.IPField.

Parameters:
  • orderable (bool | Field) –

  • searchable (bool | Field) –

  • null (bool) –

  • index (bool) –

  • unique (bool) –

  • column_name (Optional[str]) –

  • default (Any) –

  • primary_key (bool) –

  • constraints (Optional[List[SQL]]) –

  • sequence (Optional[str]) –

  • collation (Optional[str]) –

  • unindexed (bool) –

  • choices (Optional[Iterable[Tuple[str, Any]]]) –

  • help_text (Optional[str]) –

  • verbose_name (Optional[str]) –

  • index_type (Optional[str]) –

  • db_column (Optional[str]) –

  • _hidden (bool) –

Convert value for DataTables searching operation.

Parameters:

value (str) – Source value.

Return type:

str

Returns:

Converted value.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.ManyToManyField(model, backref=None, through_model=None, on_delete=None, on_update=None, prevent_unsaved=True, _is_backref=False)[source]

Bases: ManyToManyField, Field

Extending peewee.ManyToManyField.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.PrimaryKeyField(*args, **kwargs)[source]

Bases: PrimaryKeyField, AutoField

Extending peewee.PrimaryKeyField.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.SmallIntegerField(orderable=None, searchable=None, null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]

Bases: SmallIntegerField, IntegerField

Extending peewee.SmallIntegerField.

Parameters:
  • orderable (bool | Field) –

  • searchable (bool | Field) –

  • null (bool) –

  • index (bool) –

  • unique (bool) –

  • column_name (Optional[str]) –

  • default (Any) –

  • primary_key (bool) –

  • constraints (Optional[List[SQL]]) –

  • sequence (Optional[str]) –

  • collation (Optional[str]) –

  • unindexed (bool) –

  • choices (Optional[Iterable[Tuple[str, Any]]]) –

  • help_text (Optional[str]) –

  • verbose_name (Optional[str]) –

  • index_type (Optional[str]) –

  • db_column (Optional[str]) –

  • _hidden (bool) –

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.TextField(orderable=None, searchable=None, null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]

Bases: TextField, _StringField

Extending peewee.TextField.

Parameters:
  • orderable (bool | Field) –

  • searchable (bool | Field) –

  • null (bool) –

  • index (bool) –

  • unique (bool) –

  • column_name (Optional[str]) –

  • default (Any) –

  • primary_key (bool) –

  • constraints (Optional[List[SQL]]) –

  • sequence (Optional[str]) –

  • collation (Optional[str]) –

  • unindexed (bool) –

  • choices (Optional[Iterable[Tuple[str, Any]]]) –

  • help_text (Optional[str]) –

  • verbose_name (Optional[str]) –

  • index_type (Optional[str]) –

  • db_column (Optional[str]) –

  • _hidden (bool) –

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.TimeField(formats=None, *args, **kwargs)[source]

Bases: TimeField, _BaseFormattedField

Extending peewee.TimeField.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.TimestampField(*args, **kwargs)[source]

Bases: TimestampField, BigIntegerField

Extending peewee.TimestampField.

Convert value for DataTables searching operation.

Parameters:

value (datetime) – Source value.

Return type:

str

Returns:

Converted value.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.

class flask_datatables.fields.UUIDField(orderable=None, searchable=None, null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]

Bases: UUIDField, Field

Extending peewee.UUIDField.

Parameters:
  • orderable (bool | Field) –

  • searchable (bool | Field) –

  • null (bool) –

  • index (bool) –

  • unique (bool) –

  • column_name (Optional[str]) –

  • default (Any) –

  • primary_key (bool) –

  • constraints (Optional[List[SQL]]) –

  • sequence (Optional[str]) –

  • collation (Optional[str]) –

  • unindexed (bool) –

  • choices (Optional[Iterable[Tuple[str, Any]]]) –

  • help_text (Optional[str]) –

  • verbose_name (Optional[str]) –

  • index_type (Optional[str]) –

  • db_column (Optional[str]) –

  • _hidden (bool) –

Convert value for DataTables searching operation.

Parameters:

value (UUID) – Source value.

Return type:

str

Returns:

Converted value.

property dt_searchable: Field | None

DataTables default searchable field.

orderable: Union[bool, Field]

DataTables integration orderable flag.

searchable: Union[bool, Field]

DataTables integration searchable flag.