django-smalluuid
Installation
Installation using pip:
pip install django-smalluuid
Tested on:
Django >= 2.2 <= 4.0
Python 3.7, 3.8, 3.9, 3.10
Basic Usage
To get started use the SmallUUIDField field in your model definitions:
from django.db import models
from django_smalluuid.models import SmallUUIDField, uuid_default
class ExampleModel(models.Model):
uuid = SmallUUIDField(default=uuid_default())
The field provides values as instances of SmallUUID (see smalluuid):
>>> obj = ExampleModel.objects.create()
# The initial UUID has been auto-generated by uuid_default()
>>> obj.uuid
SmallUUID('T1q_P6HcQNSyW6tpqJTxww')
# It is still available in the groupex hex form (if needed)
>>> obj.hex_grouped
'4f5abf3f-a1dc-40d4-b25b-ab69a894f1c3'
# Filtering is done on the shortened UUIDs
>>> ExampleModel.objects.filter(uuid='T1q_P6HcQNSyW6tpqJTxww')
[<ExampleModel: ExampleModel object>]
Typed Usage
django-smalluuid also supports the Typed UUID’s as provided by smalluuid. This allows for the object’s type to be stored within the UUID.
Updating the above example:
from django.db import models
from django_smalluuid.models import SmallUUIDField, uuid_typed_default
class TypedExampleModel(models.Model):
uuid = SmallUUIDField(default=uuid_typed_default(type=42))
Which can be interacted with as follows:
>>> obj = TypedExampleModel.objects.create()
>>> obj.uuid
TypedSmallUUID('qvyk8nzbQfu8zAnTPQweyw')
>>> obj.uuid.type
42
Credits
django-smalluuid is packaged using seed and relies upon smalluuid.
Metadata
Release files for django-smalluuid 1.2.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 | Provenance | Actions |
|---|---|---|---|---|
| django-smalluuid-1.2.1.tar.gz | 8.8 kB | Without provenance | Details for django-smalluuid-1.2.1.tar.gz |
Release files / django-smalluuid-1.2.1.tar.gz
| Download URL | django-smalluuid-1.2.1.tar.gz |
|---|---|
| Size | 8.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a84916671992bf3f61987463964b653db7073d48c00bbc7673a47a106681c13c
|
|
BLAKE2b-256 checksum How to use checksums |
85265c9bf95f0140461cd350cb9ffae3301f7a3d2409e662579c7c8293d96a76
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.7
|
Security for django-smalluuid 1.2.1
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.