Skip to main content

django-nativeshortuuidfield

Tests Linters

Provides a NativeShortUUIDField for your Django models which uses the base-57 "Short UUID" package at https://github.com/stochastic-technologies/shortuuid/ to be used in Python and store it as full UUID in database.

Installation

Install it with pip (or easy_install):

$ pip install django-nativeshortuuidfield

Usage

First you'll need to add a NativeShortUUIDField to your class:

from native_shortuuid import NativeShortUUIDField

class MyModel(models.Model):
    uuid = NativeShortUUIDField(unique=True, default=uuid.uuid4)

If you want to add the ability to search by shortuuid in ModelAdmin you need to inherit NativeUUIDSearchMixin

from native_shortuuid.admin import NativeUUIDSearchMixin

@admin.register(models.MyModel)
class MyModelAdmin(NativeUUIDSearchMixin, admin.ModelAdmin):
    search_fields = ('uuid', )

If you want to have to ability to write your own uuid search fields list

from native_shortuuid.admin import NativeUUIDSearchMixin

@admin.register(models.MyModel)
class MyModelAdmin(NativeUUIDSearchMixin, admin.ModelAdmin):
    admin_auto_extract_uuid_search_fields = False
    search_fields = ('name', )
    search_uuid_fields = ['uuid', 'foreign_model__uuid']

Enjoy!

Settings

  • ADMIN_AUTO_EXTRACT_UUID_SEARCH_FIELDS: default True
    • This setting is to autofill search_uuid_fields in the ModelAdmins that inherits NativeUUIDSearchMixin with all shortuuid fields that are in the search_fields array. if you turned it off, you'll need to define search_uuid_fields on you ModelAdmin in order to search on shortuuid fields

Notes

  • NativeShortUUIDField is a subclass of django.db.models.UUIDField

  • You can pass usual Django UUIDField parameters on init, although some of them are added/overwritten:

    • blank=True, editable=False (set auto=False to remove these fields enforcement)

Contribution Notes

Pull Request

  • Increase the version number in the setup.py to the new version that the new pull request represents.

Publishing the Package

After the pull request gets merged into the master branch a new release should be created

  • Create a new tag with the same version number you updated the setup.py with:

    $ git checkout master
    $ git tag -a 2.1.0 -m 'fix importing order'
    $ git push origin 2.1.0
    
  • Go to GitHub's releases section and create a new release:

    • Chose the tag version that you just created
    • Fill the release title with the same version number
    • Add a description of the release and publish it

Metadata

Release files for django-nativeshortuuidfield 1.4.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-nativeshortuuidfield 1.4.11
File Size Uploaded
django_nativeshortuuidfield-1.4.11.tar.gz 11.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-nativeshortuuidfield 1.4.11
File Interpreter ABI Platform
django_nativeshortuuidfield-1.4.11-py3-none-any.whl Python 3 none any Details

Total release size: 25.4 kB

Release files / django_nativeshortuuidfield-1.4.11.tar.gz

Download URL django_nativeshortuuidfield-1.4.11.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e2a2ce2d668b9d604c76640e8a2b6f33cae6481a14d5fe86012a5f232cb87a13
BLAKE2b-256 checksum
How to use checksums
8cb9360c544bc96d685f7d013c0a15a9d59038df2d8ba2538ea363f65aaac50e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release files / django_nativeshortuuidfield-1.4.11-py3-none-any.whl

Download URL django_nativeshortuuidfield-1.4.11-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21236a82c904602aa89887f625512f388f2e0b7a51aaf89fd535e26cc3350e2f
BLAKE2b-256 checksum
How to use checksums
1f3b2948466c6c9a0e7df7fe83d8a36ebfdf3e57ce92e1ed98eb45be3dad08dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

1.4.11 This release

2 release files

1.4.9

2 release files

1.4.8

2 release files

1.4.6

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.0

2 release files

1.3.7

2 release files

1.3.6

2 release files

1.3.5

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2

2 release files

1.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page