yunojuno / django-charid-field

Provides a prefixable, string-based ID field for your Django models. Supports cuid, ksuid, ulid & more.
MIT License
33 stars 4 forks source link

Lookups fail when the string used for lookup is not correctly prefixed #3

Closed djm closed 3 years ago

djm commented 3 years ago
>>> from x.x import Contract
>>> Contract.objects.filter(public_id="")
...snip...
django.core.exceptions.ValidationError: ['“” requires the prefix “ct_”.']

This query should be allowed fine.

>>> from django.shortcuts import get_object_or_404
>>> get_object_or_404(Contract, public_id="some-random-value")
...snip...
django.core.exceptions.ValidationError: ['“” requires the prefix “ct_”.']

This query should be possible, else we can't correctly raise 404s.