Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String Related Fields #58

Closed
Lucasmiguelmac opened this issue May 9, 2022 · 1 comment
Closed

String Related Fields #58

Lucasmiguelmac opened this issue May 9, 2022 · 1 comment

Comments

@Lucasmiguelmac
Copy link

Lucasmiguelmac commented May 9, 2022

Hello there!

Is there yet a way to use something like DRF's string-related field? That is, for a model field with a relation, set it to a custom field that returns the related model's string representation.

@Lucasmiguelmac
Copy link
Author

Already figured. This can be achieved by doing the following:

class MySchema(ModelSchema):
    ...
    @validator("my_field", check_fields=False)
    def format_my_field(cls, v):
        return some_changed_value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant