GitHub - valohai/ulid2: ULID (Universally Unique Lexicographically Sortable Identifier) encoding and decoding for Python. (original) (raw)

MIT License Test codecov

ULID (Universally Unique Lexicographically Sortable Identifier) encoding and decoding for Python.

Usage

Generating ULIDs

These functions accept optional arguments:

Parsing ULIDs

Converting ULIDs

Base32

Django compatibility

As ulid2 is capable of expressing ULIDs as Python UUIDs, it's directly compatible with Django's UUIDFields. For instance, to ULID-ify a model's primary key, simply

from django.db import models from ulid2 import generate_ulid_as_uuid

class MyModel(models.Model): id = models.UUIDField(default=generate_ulid_as_uuid, primary_key=True)

and you're done!

Why the 2 in the name?

ulid is already taken by mdipierro's implementation. :)

Prior Art