Universally Unique Lexicographically Sortable Identifier (ULID) support in Django.
Status
This project is actively maintained.
Installation
To install django-ulid from pip:
$ pip install django-ulid
To install ulid from source:
$ git clone git@github.com:ahawker/django-ulid.git
$ cd django-ulid && python setup.py install
Usage
Adding a ULID field to your Django models is straightforward. It can be a normal field or a primary key.
from django.db import models
from django_ulid.models import default, ULIDField
class Person(models.Model):
id = ULIDField(default=default, primary_key=True, editable=False)
Passing in default to the ULIDField will automatically create a default value using the ulid.new function. If you do not want a default value, None by default, feel free to omit it.
from django.db import models
from django_ulid.models import ULIDField
class Person(models.Model):
optional_id = ULIDField()
Adding a ULID field to your Django REST Framework serializers is also straightforward.
Simply importing the django_ulid.serializers module will automatically register the ULIDField serializer by overriding the serializer_field_mapping on the default ModelSerializer.
from django_ulid import serializers
If you are using a ULID as a primary key on a model, you need to create a custom PrimaryKeyRelatedField to automatically serialize the instance through the foreign key.
import functools
from django_ulid.serializers import ULIDField
from rest_framework import serializers
PersonPrimaryKeyRelatedField = functools.partial(serializers.PrimaryKeyRelatedField,
allow_null=True,
allow_empty=True,
pk_field=ULIDField(),
queryset=Person.objects.all())
class OrganizationSerializer(serializers.ModelSerializer):
owner = PersonPrimaryKeyRelatedField()
Contributing
If you would like to contribute, simply fork the repository, push your changes and send a pull request. Pull requests will be brought into the master branch via a rebase and fast-forward merge with the goal of having a linear branch history with no merge commits.
License
Dependencies
Metadata
Release files for django-ulid 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django-ulid-0.0.4.tar.gz | 8.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_ulid-0.0.4-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 17.7 kB
Release files / django-ulid-0.0.4.tar.gz
| Download URL | django-ulid-0.0.4.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
56c3b302c740d01c29677f65390c72648afbe3a3109e1077ddaac2add254cbb3
|
|
BLAKE2b-256 checksum How to use checksums |
cc21a3c4d31defe114ab1c36337a9e8c91c88e9595736b216953e77b6f45444e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.1
|
Release files / django_ulid-0.0.4-py2.py3-none-any.whl
| Download URL | django_ulid-0.0.4-py2.py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
886be1fa873d28617a51cb0c1b4d9946fff30889ef031e546ac407d8160dbb74
|
|
BLAKE2b-256 checksum How to use checksums |
f6b6c42dcac423949ebbb7bd5fa33fed27e488270b76fc19b360345e7ed9b8a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.1
|
Security for django-ulid 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.