Hey all, I was doing some experimentation with UUID7. I liked it so far and started using it in two different projects.
I found this library for rust-based UUID implementation and it seems to be working relatively fast:
- https://github.com/aminalaee/uuid-utils
- https://gist.github.com/ulgens/a17dc91e314f790fa44d11f3e0debab8
But I can't use it as a field default. When I define a model like this
from uuid_utils import uuid7
class UUIDModel(models.Model):
id = models.UUIDField(
default=uuid7,
editable=False,
primary_key=True,
verbose_name="ID",
)
class Meta:
abstract = True
make and apply migrations works fine, but then model creation fails with
ValidationError: ['“0190c9d9-455d-7a41-8f69-910dbb580112” is not a valid UUID.']
which kind of misleading because it's a valid UUID, just not the UUID type Django excepts.
I tried to dive deeper and wrote new validations, but then there were other issues converting non standard UUID class to something db understands.
My question is, is there a quick solution here? Is there some sort of registry that I could say "This is a valid UUID type too, use it as same as the other"?