DTO domain types.

class litestar.dto.field.DTOField#

Bases: object

For configuring DTO behavior on model fields.

__init__(mark: Mark | Literal['read-only', 'write-only', 'private'] | None = None) None#
mark: Mark | Literal['read-only', 'write-only', 'private'] | None = None#

Mark the field as read-only, or private.

class litestar.dto.field.Mark#

Bases: str, Enum

For marking field definitions on domain models.

READ_ONLY = 'read-only'#

To mark a field that can be read, but not updated by clients.

WRITE_ONLY = 'write-only'#

To mark a field that can be written to, but not read by clients.

PRIVATE = 'private'#

To mark a field that can neither be read or updated by clients.

litestar.dto.field.dto_field(mark: Literal['read-only', 'write-only', 'private'] | Mark) dict[str, litestar.dto.field.DTOField]#

Create a field metadata mapping.


mark – A DTO mark for the field, e.g., “read-only”.


A dict for setting as field metadata, such as the dataclass “metadata” field key, or the SQLAlchemy “info” field.

Marking a field automates its inclusion/exclusion from DTO field definitions, depending on the DTO’s purpose.