djantic
djantic copied to clipboard
Pydantic 2 Support
I was testing out djantic with pydantic 2.4.2 and ran into an error caused by an import that was removed from pydantic.
File "/usr/local/lib/python3.11/site-packages/djantic/main.py", line 12, in <module>
from pydantic import BaseModel, ConfigError, create_model
ImportError: cannot import name 'ConfigError' from 'pydantic' (/usr/local/lib/python3.11/site-packages/pydantic/__init__.py)
The root cause of this appears to be that ConfigError
was removed from pydantic during the v1 -> v2 transition as mention in the migration guide
Please can this issue be solved? Also the Pydantic’s 'from_orm' method has been replaced with the 'model_validate' with a proper config for the model
I tried patching the ConfigError
issue, but immediately ran into another import problem. ModelMetaClass
, used here has been made private
Now should be _model_construction.ModelMetaclass
Yup, but I also read https://github.com/pydantic/pydantic/issues/6381 where the maintainers of pydantic mention that they want to be able to change it without it being a breaking change. If possible, it might be good to refactor djantic to avoid using it directly.
+1 for this. I'll be doing migration from Django to FastAPI and switching to V2 of Pydantic could be great
Is there someone looking at this issue already? +1 for this.
Djantic now supports pydantic 2 in a fork that I made https://github.com/jordaneremieff/djantic/issues/79