yunojuno / django-charid-field Goto Github PK
View Code? Open in Web Editor NEWProvides a prefixable, string-based ID field for your Django models. Supports cuid, ksuid, ulid & more.
License: MIT License
Provides a prefixable, string-based ID field for your Django models. Supports cuid, ksuid, ulid & more.
License: MIT License
CUID has been marked as deprecated and insecure: https://github.com/paralleldrive/cuid
They recommend migrating to CUID2: https://github.com/paralleldrive/cuid2
There is a CUID2 python port available here: https://github.com/overflowdigital/cuid2.py
Is there an example on how to use cuid2 or nanoid?
My assumption was passing a function that would return a generated id string would suffice but i keep getting weird errors, for ex:
using cuid2:
ValueError: Could not find function cuid in cuid2.generator.
ValueError: Cannot serialize: <cuid2.generator.Cuid object at 0x1030071d0>
using nanoid:
default=nanoid.generate.generate, ^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'function' object has no attribute 'generate'
>>> 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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.