Closed mthuurne closed 7 months ago
The version constraint should be 1 & 2 untill we migrate to pedantic 2 and remove support for pedantic 1. PR's welcome.
Seems with django 5.1 pydantic 2.8.2 / pydantic_core 2.20.1 is installed, which leads to a warning message:
pydantic.warnings.PydanticDeprecatedSince20: The
jsonmethod is deprecated; use
model_dump_jsoninstead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.8/migration/
As soon as I change line 24 in _config.py from
return self.json(exclude_none=True)
to
return self.model_dump_json(exclude_none=True)
the warning has gone.
So I would suspect that we can safely make this change. Shall I send a PR? But maybe I don't have the whole picture...
When I run the unit tests of an application that uses django-bootstrap-datepicker-plus, the following warning is logged:
In
pyproject.toml
of django-bootstrap-datepicker-plus, the Pydantic dependency is declared like this:This would mean that when Pydantic 3.0 is released, it will automatically get used by django-bootstrap-datepicker-plus and as a result, the code will break when it calls the removed
json()
method.I think it would be safer to include a version range for the
pydantic
dependency, either accepting versions 1 and 2 (>=1.0,<3.0
) or accepting only version 2.x (^2.0
). In the latter case, the deprecation warning could be resolved by calling the method by its newmodel_dump_json()
name instead.I'm willing to submit a PR, but first I'd have to know which strategy you want to go for.
Versions used: