vitalik / django-ninja

💨 Fast, Async-ready, Openapi, type hints based framework for building APIs
https://django-ninja.dev
MIT License
7.23k stars 429 forks source link

pydantic2 incompatibility with django-ninja 1.* #1093

Open MM-cyi opened 8 months ago

MM-cyi commented 8 months ago

Hi there.

i am trying to install django-ninja 1.* (latest), on Linux, using pip and I am constantly having issues. These issues regard the incompatibility of django-ninja and pydantic2, calling for deprecation.

File "/home/olddog/Documents/Python_Scipts/DOM_Webpage/WEBPAGE_Bilengual/Test3/.venv2/lib/python3.10/site-packages/pydantic/_internal/_config.py", line 274, in prepare_config warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning) pydantic.warnings.PydanticDeprecatedSince20: Support for class-basedconfigis deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.7/migration/

I tried to install binaries for pydantic, manually after going through the sequential installation (see shell script attached Venv_creation.sh.txt ) of my requirements.txt file. My requirements.txt goes attached to this message. requirements2_mod.txt

Anyone experienced this already? Please be so kind to advice on how to solve this problem.

Thank you Marco

vitalik commented 8 months ago

Hi @MM-cyi

You can ignore that warning - there are few edge functions that are using deprecated functionality to make migrations easier

if you starting from ninja 1.x - all should be fine

MM-cyi commented 8 months ago

Thank you for (always) replying so promptly.

It means that I can just comment out and suppress that warning? I inhibits the correct functionality of the whole chain, and my django ./manage.py runserver won't just start and work correctly.

I was thinking I could modify File "/home/olddog/Documents/Python_Scipts/DOM_Webpage/WEBPAGE_Bilengual/Test3/.venv2/lib/python3.10/site-packages/pydantic/_internal/_config.py", line 122, in for_model config_from_namespace = config_dict_from_namespace or prepare_config(config_class_from_namespace)

and

File "/home/olddog/Documents/Python_Scipts/DOM_Webpage/WEBPAGE_Bilengual/Test3/.venv2/lib/python3.10/site-packages/pydantic/_internal/_config.py", line 274, in prepare_config warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)

to get my django finally going...

danielmoessner commented 8 months ago

In this file: https://github.com/vitalik/django-ninja/blob/master/ninja/schema.py#L201 there is still old pydantic config code. Which is then referenced in other files. But if class Config could be changed to model_config that would be awesome as the warnings with pytest will disappear.