django-smalluuid
================
.. image:: https://img.shields.io/pypi/v/django-smalluuid.svg
:target: https://pypi.python.org/pypi/django-smalluuid/
.. image:: https://img.shields.io/pypi/dm/django-smalluuid.svg
:target: https://pypi.python.org/pypi/django-smalluuid/
.. image:: https://img.shields.io/github/license/adamcharnock/django-smalluuid.svg
:target: https://pypi.python.org/pypi/django-smalluuid/
.. image:: https://img.shields.io/travis/adamcharnock/django-smalluuid.svg
:target: https://travis-ci.org/adamcharnock/django-smalluuid/
.. image:: https://coveralls.io/repos/adamcharnock/django-smalluuid/badge.svg?branch=master
:target: https://coveralls.io/r/adamcharnock/django-smalluuid?branch=master
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:
.. code-block:: python
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_):
.. code-block:: python
>>> 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:
.. code-block:: python
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:
.. code-block:: python
>>> obj = TypedExampleModel.objects.create()
>>> obj.uuid
TypedSmallUUID('qvyk8nzbQfu8zAnTPQweyw')
>>> obj.uuid.type
42
Credits
-------
django-smalluuid is packaged using seed_ and relies upon smalluuid_.
.. _seed: https://github.com/adamcharnock/seed/
.. _smalluuid: https://github.com/adamcharnock/smalluuid
Raw data
{
"_id": null,
"home_page": "https://github.com/adamcharnock/django-smalluuid",
"name": "django-smalluuid",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Adam Charnock",
"author_email": "adam@adamcharnock.com",
"download_url": "https://files.pythonhosted.org/packages/85/26/5c9bf95f0140461cd350cb9ffae3301f7a3d2409e662579c7c8293d96a76/django-smalluuid-1.2.1.tar.gz",
"platform": "",
"description": "django-smalluuid\n================\n\n.. image:: https://img.shields.io/pypi/v/django-smalluuid.svg\n :target: https://pypi.python.org/pypi/django-smalluuid/\n\n.. image:: https://img.shields.io/pypi/dm/django-smalluuid.svg\n :target: https://pypi.python.org/pypi/django-smalluuid/\n\n.. image:: https://img.shields.io/github/license/adamcharnock/django-smalluuid.svg\n :target: https://pypi.python.org/pypi/django-smalluuid/\n\n.. image:: https://img.shields.io/travis/adamcharnock/django-smalluuid.svg\n :target: https://travis-ci.org/adamcharnock/django-smalluuid/\n\n.. image:: https://coveralls.io/repos/adamcharnock/django-smalluuid/badge.svg?branch=master\n :target: https://coveralls.io/r/adamcharnock/django-smalluuid?branch=master\n\n\n\nInstallation\n------------\n\nInstallation using pip::\n\n pip install django-smalluuid\n\nTested on:\n\n * Django >= 2.2 <= 4.0\n * Python 3.7, 3.8, 3.9, 3.10\n\n\nBasic Usage\n-----------\n\nTo get started use the ``SmallUUIDField`` field in your model definitions:\n\n.. code-block:: python\n\n from django.db import models\n from django_smalluuid.models import SmallUUIDField, uuid_default\n\n class ExampleModel(models.Model):\n uuid = SmallUUIDField(default=uuid_default())\n\nThe field provides values as instances of ``SmallUUID`` (see smalluuid_):\n\n.. code-block:: python\n\n >>> obj = ExampleModel.objects.create()\n\n # The initial UUID has been auto-generated by uuid_default()\n >>> obj.uuid\n SmallUUID('T1q_P6HcQNSyW6tpqJTxww')\n\n # It is still available in the groupex hex form (if needed)\n >>> obj.hex_grouped\n '4f5abf3f-a1dc-40d4-b25b-ab69a894f1c3'\n\n # Filtering is done on the shortened UUIDs\n >>> ExampleModel.objects.filter(uuid='T1q_P6HcQNSyW6tpqJTxww')\n [<ExampleModel: ExampleModel object>]\n\n\nTyped Usage\n-----------\n\n``django-smalluuid`` also supports the Typed UUID's as provided by smalluuid_. This\nallows for the object's type to be stored within the UUID.\n\nUpdating the above example:\n\n.. code-block:: python\n\n from django.db import models\n from django_smalluuid.models import SmallUUIDField, uuid_typed_default\n\n class TypedExampleModel(models.Model):\n uuid = SmallUUIDField(default=uuid_typed_default(type=42))\n\nWhich can be interacted with as follows:\n\n.. code-block:: python\n\n >>> obj = TypedExampleModel.objects.create()\n >>> obj.uuid\n TypedSmallUUID('qvyk8nzbQfu8zAnTPQweyw')\n >>> obj.uuid.type\n 42\n\n\nCredits\n-------\n\ndjango-smalluuid is packaged using seed_ and relies upon smalluuid_.\n\n.. _seed: https://github.com/adamcharnock/seed/\n.. _smalluuid: https://github.com/adamcharnock/smalluuid\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Short-form UUID field for Django 1.8 and above",
"version": "1.2.1",
"project_urls": {
"Homepage": "https://github.com/adamcharnock/django-smalluuid"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "85265c9bf95f0140461cd350cb9ffae3301f7a3d2409e662579c7c8293d96a76",
"md5": "49ea82120780b4769d4072b69b1f3847",
"sha256": "a84916671992bf3f61987463964b653db7073d48c00bbc7673a47a106681c13c"
},
"downloads": -1,
"filename": "django-smalluuid-1.2.1.tar.gz",
"has_sig": false,
"md5_digest": "49ea82120780b4769d4072b69b1f3847",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 8840,
"upload_time": "2022-02-21T09:44:40",
"upload_time_iso_8601": "2022-02-21T09:44:40.985440Z",
"url": "https://files.pythonhosted.org/packages/85/26/5c9bf95f0140461cd350cb9ffae3301f7a3d2409e662579c7c8293d96a76/django-smalluuid-1.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-02-21 09:44:40",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "adamcharnock",
"github_project": "django-smalluuid",
"travis_ci": true,
"coveralls": false,
"github_actions": true,
"lcname": "django-smalluuid"
}