ULID (Universally Unique Lexicographically Sortable Identifier) support for Django.
Project description
python-ulid-django
ULID (Universally Unique Lexicographically Sortable Identifier) support for Django.
This package uses the ULID type implemented by python-ulid.
This package is heavily inspired by
django-ulid. The reason I'm reinventing the wheel is that I want to usepython-ulib's ULID implementation.
Usage
Installation
pip install python-ulid-django
Model Field
You can then add ULIDField to your Django model just like other fields.
Example:
from django.contrib.auth.models import AbstractUser
from ulid import ULID
from ulid_django.models import ULIDField
class User(AbstractUser):
id = ULIDField(primary_key=True, default=ULID, editable=False)
URL Converter
There is also a URL converter can be used.
from django.urls import path, register_converter
from ulid import ULID
from ulid_django.converters import ULIDConverter
def user_detail_view(request, user_id):
assert isinstance(user_id, ULID)
...
register_converter(ULIDConverter, "ulid")
urlpatterns = [
path("user/<ulid:user_id>/", user_detail_view),
...,
]
Development
Prerequisite: PDM
Environment setup: pdm sync
Run linters: pdm lint
Test: pdm test
Project details
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 python_ulid_django-1.4.0.tar.gz.
File metadata
- Download URL: python_ulid_django-1.4.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.6 CPython/3.13.6 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38d42dff556c0922bde117969c75d610648b3a8aa8e7eb64197af109c7db489e
|
|
| MD5 |
2359f071b1cd750fd042af92c593b880
|
|
| BLAKE2b-256 |
ffd9b138bb6c71b7da0daaf6f40deef21c0264896b6bf0d8c39089016cd7b2b3
|
File details
Details for the file python_ulid_django-1.4.0-py3-none-any.whl.
File metadata
- Download URL: python_ulid_django-1.4.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.6 CPython/3.13.6 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
644fc09b4a8b696c1a46db42dd7b25d57d6e6a2f4b104c7f595fff99fa2d2e85
|
|
| MD5 |
49f65c87b331708fe7339c6b96aed20d
|
|
| BLAKE2b-256 |
863b83e8bdc5a5e1ede1eaffe2847eb192608316abc68ebb5eff4dbc75817b95
|