Skip to main content

Auto-incrementing fields like Django AutoField but without restrictions!

Project description

identityfield

Auto-incrementing fields like Django AutoField but without restrictions!

This reusable app provides fields that are using PostgreSQL GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY. Same as Django AutoField. But without primary_key=true limitation.

Installation

https://pypi.org/project/django-identityfield/

  • uv add django-identityfield
  • add "identityfield" to your settings.INSTALLED_APPS

Usage

from django.db import models
from identityfield import IdentityField, Identity


class HappyModel(models.Model):
    sequence = IdentityField()
    # ALWAYS rejects any value other than DEFAULT in UPDATE
    always_sequence = IdentityField(identity=Identity.ALWAYS)

DB sequences are automatically created by PostgreSQL. And are automatically incremented on DB side.

https://www.postgresql.org/docs/current/ddl-identity-columns.html

Running test suite

uv run pytest
uvx tox

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_identityfield-0.2.0.tar.gz (1.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_identityfield-0.2.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file django_identityfield-0.2.0.tar.gz.

File metadata

File hashes

Hashes for django_identityfield-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2e30a310992b8a51a49d67403e29633ef50158765246b4d7a00fb505cdb6d4bd
MD5 68cd8c589bf9bfb6fc5bf19c93ba83c4
BLAKE2b-256 92a925dfa51d1f1aa8f9951a4959f39e043ad371ee8c07990b8b68254df3b589

See more details on using hashes here.

File details

Details for the file django_identityfield-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_identityfield-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ec9dd4e636bf52276f653ed2b2f97f433f66f7f7b4d9d63336dcba0477f9b48d
MD5 074e76a020923ab84a182df6d7a95192
BLAKE2b-256 2ccb498a0e355c96ba05f567475c74b9a01fb541c3d301ff3fd6fba360111c9e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page