TypeID Field for Django
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_typeid_field-0.0.1.tar.gz.
File metadata
- Download URL: django_typeid_field-0.0.1.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
904abb2dd256b1a6d6182c2462eb8765c7d058da93f30b6a692d71bafeb387b8
|
|
| MD5 |
29f5a4b4c8e9e271e8de8c1ec44f36db
|
|
| BLAKE2b-256 |
956f186bb204d60d563b0b3d77b1588f72b7a5b0f13eb959fd167e1d027bca61
|
File details
Details for the file django_typeid_field-0.0.1-py3-none-any.whl.
File metadata
- Download URL: django_typeid_field-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab352779a077a053ef3ba3007412012de345323ea3137d7b4a1abedefd5bc1b1
|
|
| MD5 |
c68a1898cce188ecb7166b6e52fe9091
|
|
| BLAKE2b-256 |
781bbd157816040d911c0808feb08b34b702499dacd70ebfe3c17a5f23b5a2c5
|