Skip to content

v0.5.0: Architecture cleanup and better type hints

Choose a tag to compare

@surenkov surenkov released this 13 Jan 19:54
· 23 commits to master since this release
c864cfb

Version 0.5.0 Release Notes

The core adaptation logic is moved into a SchemaAdapter layer that handles both Pydantic v1 and v2 through the same interface.

Key Improvements

  • Cleaner Internal Architecture:
    By moving logic into SchemaAdapter, we’ve eliminated a lot of “if Pydantic v2 do this, else do that” code. This makes the field behavior identical regardless of which Pydantic version you are running.
  • Stricter Pydantic v1 Isolation:
    For those still using Pydantic v1 models, they are now more effectively isolated within the .v1 subpackage.
    If you are running Pydantic v2 but still need to use legacy Pydantic v1 models, you can now do so explicitly by importing the field from the .v1 subpackage:
from django_pydantic_field.v1 import SchemaField as SchemaFieldV1
  • Modernized Development Tooling:
    The project has switched to uv for dependency management and building. This won’t affect library users, but it makes contributing easier.

Breaking Changes

  • Lazy Schema Resolution for Pydantic v1:
    To match the behavior of Pydantic v2 fields, v1 fields now resolve their schemas lazily. Previously, v1 schemas were resolved during Django Model class initialization. Now, resolution is deferred until the field is accessed. This allows for easier handling of forward references but may change the timing of when field errors are raised.
  • CoreAPI Support Removed:
    Following Django REST Framework, we have dropped support for CoreAPI. If you need schema generation, please use the OpenAPI-based AutoSchema provided in django_pydantic_field.rest_framework.
  • New Source Layout:
    The project now follows the standard src/ layout. This shouldn’t affect standard installations, but if you were importing from internal file paths or using a non-standard setup, you may need to adjust your configuration.

What's Changed

  • chore: switch to uv by @surenkov in #89
  • Unify field logic using SchemaAdapter for Pydantic v1 and v2 by @surenkov in #90
  • Refactor compatibility layer and improve Pydantic v1/v2 isolation by @surenkov in #91
  • Refactor SchemaField for better Pydantic V1/V2 support by @surenkov in #92
  • Update README.md by @surenkov in #93
  • Upgrade dev dependencies and fix test suite for Pydantic V2/Pytest 9 by @surenkov in #94

Full Changelog: v0.4.1...v0.5.0