Skip to content

Accessing and displaying the Field description attribute #1494

Answered by byrman
clstaudt asked this question in Questions
Discussion options

You must be logged in to vote

By accessing your model's __fields__ attribute?

for k, v in Contract.__fields__.items():
    print(f"{k}: {v.field_info.description}")

UPD YuriiMotov: use model_fields in Pydantic V2

print(Contract.model_fields["title"])

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by YuriiMotov
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
4 participants
Converted from issue

This discussion was converted from issue #246 on August 12, 2025 11:08.