First Check
Commit to Help
Example Code
class Contract(SQLModel, table=True):
"""A contract defines the business conditions of a project"""
id: Optional[int] = Field(default=None, primary_key=True)
title: str = Field(description="Short description of the contract.")
client: Client = Relationship(
back_populates="contracts",
)
signature_date: datetime.date = Field(
description="Date on which the contract was signed",
)
start_date: datetime.date = Field(
description="Date from which the contract is valid",
)
end_date: Optional[datetime.date] = Field(
description="Date until which the contract is valid",
)
Description
I was happy to find out that every attribute of a SQLModel class can be documented with ... = Field(description="attribute meaning here"). Let's do more of that. However, I was confused when I tried to access and display the field description and didn't find a way to do that.
Given the example class Contract, accessing Contract.signature_date.description gives the following output: 'signature_date'
- This output is so counter-intuitive that it may be a bug
- How do I access the string I supplied with the
Field(description=...) argument?
- Is there a neat way to show all the fields with their descriptions?
Operating System
macOS
Operating System Details
No response
SQLModel Version
0.0.6
Python Version
Python 3.9.7
Additional Context
No response
First Check
Commit to Help
Example Code
Description
I was happy to find out that every attribute of a SQLModel class can be documented with
... = Field(description="attribute meaning here"). Let's do more of that. However, I was confused when I tried to access and display the field description and didn't find a way to do that.Given the example class
Contract, accessingContract.signature_date.descriptiongives the following output:'signature_date'Field(description=...)argument?Operating System
macOS
Operating System Details
No response
SQLModel Version
0.0.6
Python Version
Python 3.9.7
Additional Context
No response