Fieldsο
The YDB backend supports most built-in Django fields. The table below is both the support status and the exact YDB type mapping for each field.
Legend: β supported Β· π‘ works with caveats (see the note) Β· β unsupported or not enforced by YDB.
Field |
YDB type |
Python |
Notes |
|
|---|---|---|---|---|
|
β |
|
int |
Value generated by YDB. |
|
β |
|
str |
|
|
β |
|
str |
|
|
β |
|
bytes |
|
|
β |
|
str |
|
|
β |
|
bool |
|
|
β |
|
int |
Signed integer chosen by range. |
|
β |
|
int |
Unsigned integer chosen by range. |
|
β |
|
float |
Cannot be a primary key. |
|
β |
|
Decimal |
Arbitrary |
|
β |
|
uuid.UUID |
Native UUID. |
|
β |
|
int |
Β±136 years; cannot be a primary key. Temporal subtraction supported. |
|
β |
|
datetime.date |
Signed wide date β dates before 1970 are supported. |
|
π‘ |
|
datetime.datetime |
Microsecond precision, instants before 1970. Under |
|
π‘ |
|
datetime.time |
No native time type β stored as microseconds since midnight, introspected back as |
|
π‘ |
|
dict / list / str / int / float / bool |
Equality filtering ( |
Relationship fieldsο
ForeignKey,
OneToOneField,
and ManyToManyField
work through the Django ORM. A relation is stored as a plain scalar <name>_id
column typed from the targetβs primary key (ManyToManyField uses an ordinary
through table); you define relations, query them, and traverse them with
select_related (and prefetch_related, with a few edge cases) as usual.
What YDB does not do is enforce any of the relational guarantees at the database level:
no
FOREIGN KEY/REFERENCES/ON DELETEis emitted or introspected;there is no cascade delete at the database level β Djangoβs ORM
on_deletestill runs for ORM deletes, but raw SQL or external writers can orphan rows;one-to-one and many-to-many-pair uniqueness is not enforced β the ORM declaration is accepted, but duplicates are not rejected.
Enforce these in application code (validate_unique(), clean(), validators)
where you need them. For example:
class Product(models.Model):
sku = models.CharField(max_length=20, primary_key=True)
class ProductReview(models.Model):
product = models.ForeignKey(Product, on_delete=models.CASCADE)
rating = models.IntegerField()
ProductReview.product is stored as a product_id column with the same YDB type
as Product.sku. An insert writes the referenced key value only:
ProductReview.objects.create(product_id="SKU-1", rating=5)
YDB accepts this row even if no Product(sku="SKU-1") exists.