This release is a pre-release and may not be stable for production use.
Orm-Converter
Installation
pip install orm-converter
or
pip install git+https://github.com/MaxZayats/orm-converter
Available conversions
TortoiseORM->DjangoORM
Usage Examples
1. Simple Usage
from orm_converter.tortoise_to_django import ConvertedModel
from tortoise import fields
from tortoise.models import Model as TortoiseModel
class ExampleModel(TortoiseModel, ConvertedModel):
example_field = fields.IntField()
ExampleModel.DjangoModel # <- Converted Django Model
2. Redefining fields/attributes
from orm_converter.tortoise_to_django import (ConvertedModel,
RedefinedAttributes)
from tortoise.models import Model as TortoiseModel
from custom_django_fields import CustomDjangoField
from custom_tortoise_fields import CustomTortoiseField
class ExampleModel(TortoiseModel, ConvertedModel):
custom_field = CustomTortoiseField()
class RedefinedAttributes(RedefinedAttributes):
"""
In this class you can redefine your tortoise attributes to django attributes.
You can use this if you have a custom fields
Or if `orm_converter` converts fields incorrectly.
"""
custom_field = CustomDjangoField()
3. Adding custom converters
from orm_converter.tortoise_to_django import (BaseTortoiseFieldConverter,
ConvertedModel, Converter)
from tortoise.models import Model as TortoiseModel
from custom_django_fields import CustomDjangoField
from custom_tortoise_fields import CustomTortoiseField
class MyCustomFieldConverter(BaseTortoiseFieldConverter):
ORIGINAL_FIELD_TYPE = CustomTortoiseField
CONVERTED_FIELD_TYPE = CustomDjangoField
def _reformat_kwargs(self):
super()._reformat_kwargs()
# change field kwargs here
self._original_field_kwargs["custom_kwarg"] = "Django"
Converter.add_converters(MyCustomFieldConverter)
class ExampleModel(TortoiseModel, ConvertedModel):
custom_field = CustomTortoiseField(custom_kwarg="Tortoise")
Metadata
Release files for orm-converter 0.2.2b0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| orm_converter-0.2.2b0.tar.gz | 6.8 kB | Without provenance | Details for orm_converter-0.2.2b0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| orm_converter-0.2.2b0-py3-none-any.whl | Python 3 | none | any | Details for orm_converter-0.2.2b0-py3-none-any.whl |
Total release size: 14.6 kB
Release files / orm_converter-0.2.2b0.tar.gz
| Download URL | orm_converter-0.2.2b0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f595f37c58a704542ee94f3bb7b412397a1d4ea07fb31006a299ac7ba930edff
|
|
BLAKE2b-256 checksum How to use checksums |
4fabd9f1fcfc4e8c674ee9a57ba4e35c690e4de2afb8bd9659d0d4c61866337c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.5
|
Release files / orm_converter-0.2.2b0-py3-none-any.whl
| Download URL | orm_converter-0.2.2b0-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c2a16643d2194c04a25a128bbf5c63b35cbc97c93732bf2f87617d826647b181
|
|
BLAKE2b-256 checksum How to use checksums |
6219f6d3fb8f3c10777d55a9fbc684495717946304e77e4975a118567e753c45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.5
|
Security for orm-converter 0.2.2b0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.