-
-
Notifications
You must be signed in to change notification settings - Fork 162
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
AttributeError: 'FieldInfo' object has no attribute 'name' #190
Comments
Hello, I encountered the same problem and by downgrading pydentic to |
Duplicate with: #189 |
Thanks for your great advice. pip install "pydantic==1.*" The problem occurs when pydantic2.x modifies BaseModel.__fields__ I provide a feasible solution here, just modify the # for handle pydantic 2.x migration
from pydantic import __version__ as pydantic_version
if int(pydantic_version.split('.')[0]) >= 2:
# pydantic 2.x
fields = {
fk: (fv.annotation, ...)
for fk,fv in schema_cls.model_fields.items()
if fk != pk_field_name
}
else:
# pydantic 1.x
fields = {
f.name: (f.type_, ...)
for f in schema_cls.__fields__.values()
if f.name != pk_field_name
} I'll submit a Pull Request to fix this later. |
I got this problem when I just try the demo!
Python3.11.4
The text was updated successfully, but these errors were encountered: