Skip to content
Discussion options

You must be logged in to vote

This is not a supported feature.

Conceptually, DTOs are not designed to work this way.

Examining your code closely:

data: DTOData[OrderModel] means "I want a DTOData object here, having all the fields of the DTO for OrderModel".

class OrderCreateDTO(SQLAlchemyDTO[OrderModel]):
    config = SQLAlchemyDTOConfig(
        include={"amount", "user_ids"},
    )

and this means "Create a DTO for OrderModel and include its amount and user_ids fields". But OrderModel does not have a user_ids field.


The simple answer is, that if you want a field on your model, you'll have to put it on your model. DTOs are intended to transform data from one shape to another; They are not intended to model data.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dilkhushvakhabov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants