config#
- class litestar.dto.config.DTOConfig#
Bases:
object
Control the generated DTO.
- exclude: AbstractSet[str]#
Explicitly exclude fields from the generated DTO.
If exclude is specified, all fields not specified in exclude will be included by default.
Notes
- The field names are dot-separated paths to nested fields, e.g.
"address.street"
will exclude the
"street"
field from a nested"address"
model.
- The field names are dot-separated paths to nested fields, e.g.
- ‘exclude’ mutually exclusive with ‘include’ - specifying both values will raise an
ImproperlyConfiguredException
.
- include: AbstractSet[str]#
Explicitly include fields in the generated DTO.
If include is specified, all fields not specified in include will be excluded by default.
Notes
- The field names are dot-separated paths to nested fields, e.g.
"address.street"
will include the
"street"
field from a nested"address"
model.
- The field names are dot-separated paths to nested fields, e.g.
- ‘include’ mutually exclusive with ‘exclude’ - specifying both values will raise an
ImproperlyConfiguredException
.
- rename_strategy: RenameStrategy | None = None#
Rename all fields using a pre-defined strategy or a custom strategy.
The pre-defined strategies are: upper, lower, camel, pascal.
A custom strategy is any callable that accepts a string as an argument and return a string.
Fields defined in
rename_fields
are ignored.
- __init__(exclude: AbstractSet[str] = <factory>, include: AbstractSet[str] = <factory>, rename_fields: dict[str, str] = <factory>, rename_strategy: RenameStrategy | None = None, max_nested_depth: int = 1, partial: bool = False, underscore_fields_private: bool = True, experimental_codegen_backend: bool | None = None, forbid_unknown_fields: bool = False) None #