Django TypeID Field
TypeID is a type-safe extension of UUIDv7, encoding UUIDs in base32 and adding a type prefix. This package provides a field to use in models. For more details about TypeID, visit the TypeID GitHub repository.
Installation
Install it from PyPI:
pip install django-typeid-field
Usage
First, add it to your applications (Not Required)
INSTALLED_APPS = [
# ...
'typeid_field',
# ...
]
You can now use it in your models like:
from django.db import models
from typeid_field import TypeidField
class Profile(models.Model):
hash = TypeidField(prefix='profile')
TypeidField
This model field is based on CharField. All of it's parameters can be used.
Additionally following fields affects outcome of TypeID:
prefix Parameter (Optional)
Specifies the type prefix for the generated TypeID, which impacts the length of the ID and the field in the database. The prefix can be up to 63 characters long, must contain only lowercase alphabetic ASCII characters or underscores, and cannot start or end with an underscore. If the prefix is empty, no separator is used.
Using TypeidField as primary_key
To use TypeID as default primary_key you need to explicitly define it in your
model:
from django.contrib.auth.models import AbstractUser
from django.db import models
class SomeModel(models.Model):
id = TypeidField(primary_key=True, editable=False) # 2x4y6z8a0b1c2d3e4f5g6h7j8k
# ...
class CustomUser(AbstractUser):
id = TypeidField(primary_key=True, editable=False, prefix='user') # user_2x4y6z8a0b1c2d3e4f5g6h7j8k
# ...
Credits
This package is based on django-nanoid-field.
Release files for django-typeid-field 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_typeid_field-0.0.1.tar.gz | 3.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_typeid_field-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:7.4 kB
Release files / django_typeid_field-0.0.1.tar.gz
| Download URL | django_typeid_field-0.0.1.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
904abb2dd256b1a6d6182c2462eb8765c7d058da93f30b6a692d71bafeb387b8
|
|
BLAKE2b-256 checksum How to use checksums |
956f186bb204d60d563b0b3d77b1588f72b7a5b0f13eb959fd167e1d027bca61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.4
|
Release files / django_typeid_field-0.0.1-py3-none-any.whl
| Download URL | django_typeid_field-0.0.1-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ab352779a077a053ef3ba3007412012de345323ea3137d7b4a1abedefd5bc1b1
|
|
BLAKE2b-256 checksum How to use checksums |
781bbd157816040d911c0808feb08b34b702499dacd70ebfe3c17a5f23b5a2c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.0.0 CPython/3.12.4
|