Skip to content

Releases: surenkov/django-pydantic-field

v0.2.5

13 Jun 21:21
Compare
Choose a tag to compare
v0.2.5 Pre-release
Pre-release

What's Changed

  • Add a bit of integration tests for models, forms and serializers by @surenkov in #17
  • Properly override get_prep_value and get_db_prep_value methods for PydanticSchemaField by @surenkov in #20

Important note:

This release fixes #19, thus Django < 4.2 users should avoid installing previous one, v0.2.4.
I'm considering to delist 0.2.4 from PyPI to minimize the potential harm.

Full Changelog: v0.2.4...v0.2.5

v0.2.4

03 May 19:02
Compare
Choose a tag to compare
v0.2.4 Pre-release
Pre-release

What's Changed

Full Changelog: v0.2.3...v0.2.4

v0.2.3

25 Feb 11:03
34f717c
Compare
Choose a tag to compare
v0.2.3 Pre-release
Pre-release

What's Changed

  • Migrate setup.cfg to the sole pyproject.toml by @surenkov in #13
  • Extract pydantic export kwargs from fields' __init__ before calling super().__init__ by @surenkov in #14

Closed: #12

Full Changelog: v0.2.2...v0.2.3

v0.2.2

14 Nov 16:04
Compare
Choose a tag to compare
v0.2.2 Pre-release
Pre-release

What's Changed

Full Changelog: v0.2.1...v0.2.2

Properly declare supported Django versions

02 Oct 12:28
Compare
Choose a tag to compare

The package supports Django starting from 3.1.

Full Changelog: v0.2.0...v0.2.1

v0.2.0: Django 3.2 support

01 Oct 16:00
Compare
Choose a tag to compare
Pre-release

What's Changed

Full Changelog: v0.1.13...v0.2.0

v0.1.13: Django form field support

18 Sep 15:13
4caf809
Compare
Choose a tag to compare
Pre-release

What's Changed

Full Changelog: v0.1.12...v0.1.13

v0.1.12: Union types support

16 Sep 14:54
Compare
Choose a tag to compare
Pre-release

Un additin to typed collections and pydantic types, the field now also supports typing.Union, its special forms like typing.Optional and (only for py 3.10+) X | Y union annotations syntax.

What's Changed

Full Changelog: v0.1.11...v0.1.12

Enfoced null checks for `SchemaField`

14 Sep 14:42
Compare
Choose a tag to compare
Pre-release

Enforced null checks for SchemaField

In the example below, typing linters should enforce type compatibility:

class BuildingMeta(pydantic.BaseModel):
    type: Optional[BuildingTypes]

class Building(models.Model):
    opt_meta: BuildingMeta = SchemaField(default={"type": "frame"}, null=True)
    meta: Optional[BuildingMeta] = SchemaField(default={"type": "frame"})

Pyright will complain on both fields:

sample_app/models.py:5:32 - error: Expression of type "BuildingMeta | None" cannot be assigned to declared type "BuildingMeta"
sample_app/models.py:6:40 - error: Expression of type "ST@SchemaField" cannot be assigned to declared type "BuildingMeta | None"

Mypy has more broaden resolution for latter check, but still be able to recognise first one:

sample_app/models.py:5: error: Incompatible types in assignment (expression has type "Optional[BuildingMeta]", variable has type "BuildingMeta")

Fixing field annotations will resolve issues on both checkers:

class Building(models.Model):
    opt_meta: Optional[BuildingMeta] = SchemaField(default={"type": "frame"}, null=True)
    meta: BuildingMeta = SchemaField(default={"type": "frame"})

The check also enforces default=None to have null=True param.

Relaxed restrictions on default= argument

In addition to null enforcement, typing checks allow arbitrary values for default= argument, as long as they are acceptable for pydantic's BaseModel.parse_obj method. Callables are also accepted, mimicking Django's field semantics.

Full Changelog: v0.1.10...v0.1.11

v0.1.10

13 Sep 21:22
Compare
Choose a tag to compare
v0.1.10 Pre-release
Pre-release

Slightly improve inheritance chain, better typings for SchemaField factory function.

Full Changelog: v0.1.9...v0.1.10