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.1.2.tar.gz (1.8 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.1.2-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for django_identityfield-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f858b89db3e5343a69240fc274a53b77ce4a9c4a85c6fd037dd0e9ecadd023d6
MD5 e23718a0584bf01e4adb7c8358a2e17c
BLAKE2b-256 0cdb62ded8dfaf55437e63e2d8b5e72385eea05185b02bd92de78c6ba7756225

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_identityfield-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 71813ae2a2076cd2aeb7baa0b33f1dddd19205bbb5b971a35a2d3a917a77dafb
MD5 d926c03984747d7ddb61b01516c7b49a
BLAKE2b-256 884bb304a4b1863c277f48096106aed44a45b99a5941945bb3cfdc8fd23edc17

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