Fields

BaseField

class aiogram.types.fields.BaseField(*, base=None, default=None, alias=None, on_change=None)[source]

Bases: object

Base field (prop)

Init prop

Parameters
  • base – class for child element

  • default – default value

  • alias – alias name (for e.g. field ‘from’ has to be named ‘from_user’ as ‘from’ is a builtin Python keyword

  • on_change – callback will be called when value is changed

get_value(instance)[source]

Get value for the current object instance

Parameters

instance

Returns

set_value(instance, value, parent=None)[source]

Set prop value

Parameters
  • instance

  • value

  • parent

Returns

abstract serialize(value)[source]

Serialize value to python

Parameters

value

Returns

abstract deserialize(value, parent=None)[source]

Deserialize python object value to TelegramObject value

export(instance)[source]

Alias for serialize but for current Object instance

Parameters

instance

Returns

Field

class aiogram.types.fields.Field(*, base=None, default=None, alias=None, on_change=None)[source]

Bases: aiogram.types.fields.BaseField

Simple field

Init prop

Parameters
  • base – class for child element

  • default – default value

  • alias – alias name (for e.g. field ‘from’ has to be named ‘from_user’ as ‘from’ is a builtin Python keyword

  • on_change – callback will be called when value is changed

serialize(value)[source]

Serialize value to python

Parameters

value

Returns

deserialize(value, parent=None)[source]

Deserialize python object value to TelegramObject value

ListField

class aiogram.types.fields.ListField(*args, **kwargs)[source]

Bases: aiogram.types.fields.Field

Field contains list ob objects

Init prop

Parameters
  • base – class for child element

  • default – default value

  • alias – alias name (for e.g. field ‘from’ has to be named ‘from_user’ as ‘from’ is a builtin Python keyword

  • on_change – callback will be called when value is changed

serialize(value)[source]

Serialize value to python

Parameters

value

Returns

deserialize(value, parent=None)[source]

Deserialize python object value to TelegramObject value

ListOfLists

class aiogram.types.fields.ListOfLists(*, base=None, default=None, alias=None, on_change=None)[source]

Bases: aiogram.types.fields.Field

Init prop

Parameters
  • base – class for child element

  • default – default value

  • alias – alias name (for e.g. field ‘from’ has to be named ‘from_user’ as ‘from’ is a builtin Python keyword

  • on_change – callback will be called when value is changed

serialize(value)[source]

Serialize value to python

Parameters

value

Returns

deserialize(value, parent=None)[source]

Deserialize python object value to TelegramObject value

DateTimeField

class aiogram.types.fields.DateTimeField(*, base=None, default=None, alias=None, on_change=None)[source]

Bases: aiogram.types.fields.Field

In this field st_ored datetime

in: unixtime out: datetime

Init prop

Parameters
  • base – class for child element

  • default – default value

  • alias – alias name (for e.g. field ‘from’ has to be named ‘from_user’ as ‘from’ is a builtin Python keyword

  • on_change – callback will be called when value is changed

serialize(value: datetime.datetime)[source]

Serialize value to python

Parameters

value

Returns

deserialize(value, parent=None)[source]

Deserialize python object value to TelegramObject value

TextField

class aiogram.types.fields.TextField(*, prefix=None, suffix=None, default=None, alias=None)[source]

Bases: aiogram.types.fields.Field

Init prop

Parameters
  • base – class for child element

  • default – default value

  • alias – alias name (for e.g. field ‘from’ has to be named ‘from_user’ as ‘from’ is a builtin Python keyword

  • on_change – callback will be called when value is changed

serialize(value)[source]

Serialize value to python

Parameters

value

Returns

deserialize(value, parent=None)[source]

Deserialize python object value to TelegramObject value