Open jleclanche opened 1 year ago
@jleclanche
ok, will think about it - PRs/hints are welcome :)
BTW for now you can override TYPES with your own types fallbackes - see example here https://github.com/vitalik/django-ninja/issues/694#issuecomment-1456543192
I use prefixed UUIDv7 as ID fields in my database. The field looks like this:
UUIDv7 is great. It's lexicographically sortable, and the prefix means I can distinguish one ID from another and have a created timestamp without storing extra information in the db. So the idea is that the API returns IDs such as
org_BwFJbmSZpBC3YZXUm3jjG
, instead of0186de4c-f634-7baa-9a1f-d77dbe2296eb
.But when I give a model with that field to python, I get this pydantic error:
Ideally, Django Ninja should be able to tell what the actual type should be, thanks to the
from_db_value
type hint. Failing that, is there an easier way to hint at ModelSchema what the type is supposed to be, that doesn't involve adding a custom field everywhere it's missing?