Skip to main content

Storing DTO data in easy-to-use and production-ready Django Model Field with fast [de]serialization.

Project description

django-dto-field

PyPI version PyPI license Python Version

wemake-python-styleguide test typing & lint

Storing DTO data in easy-to-use and production-ready Django Model Field with fast [de]serialization.

A custom Django Model Field that can serialize and deserialize for different types of DTO (Data-Transfer-Object). DtoField detect DTO type and serialize the most efficiently. Also it has own binary container to maintain data integrity and economical storage.

✨ Features

  • All DB support (if DB support BinaryFiled)
  • Zip field for size saving (optional)
  • Supports pure dict as DTO
  • Supports TypedDict as DTO
  • Supports dataclass as DTO
  • Supports pydantic as DTO
  • Supports marshmallow as DTO
  • Supports attrs as DTO
  • Supports adapdtix as DTO

⬇️ Install

$ pip install django-dto-field

🚀 Quick start

Set DTO field to your model:

>>> from django.db.models import CharField
>>> from django_dto_field import DtoField

>>> class Country(Model):
...    name = CharField()
...    city = DtoField()

And than use it:

>>> city = {"name": "Capitol", "districts": [f"d{i}" for i in range(1, 14)]}
>>> created_country = Country.objects.create(name="Panem", city=city)

>>> from_db_country = Country.objects.get(pk=created_country.pk)
>>> assert isinstance(from_db_country.city, dict)
>>> assert from_db_country.city == city

🤗 Author

Made with love by @skv0zsneg

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_dto_field-0.1.0a2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_dto_field-0.1.0a2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file django_dto_field-0.1.0a2.tar.gz.

File metadata

  • Download URL: django_dto_field-0.1.0a2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.0 CPython/3.12.13 Linux/6.17.0-1008-azure

File hashes

Hashes for django_dto_field-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 fcaaf11ab86451a43b9f241989ad82cefb9a334336def5a143c891023bb7f2b2
MD5 910c4201f6c24171bf725c0c1756fe57
BLAKE2b-256 bef8c9c2312272efbfa5af3329bb7b9f194f56e163cf59026356dc5a6cd51c02

See more details on using hashes here.

File details

Details for the file django_dto_field-0.1.0a2-py3-none-any.whl.

File metadata

  • Download URL: django_dto_field-0.1.0a2-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.0 CPython/3.12.13 Linux/6.17.0-1008-azure

File hashes

Hashes for django_dto_field-0.1.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 02099c47f759e8d7ce04f56509f2210e1dc0e12cd6c6841ff4800cd55657b57c
MD5 898a8465848186515fe278726fdb6911
BLAKE2b-256 806b314ba165fa7068d3ab9bc570b42d471ba40c33a8891e3ea95dfd6650b5fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page