Skip to main content

Django field and PostgreSQL backend for infinity timestamp support with psycopg3

Project description

Django field and PostgreSQL backend for infinity timestamp support with psycopg >=3.

Maps PostgreSQL’s infinity / -infinity timestamp values to datetime.max / datetime.min in Python, making them usable as regular DateTimeField values in Django models.

Currently only DateTimeField is supported. DateField and TimeField infinity values are not yet handled. Contributions welcome!

Installation

pip install django-psycopg-infinity

Configuration

Set the custom database backend in your Django settings:

DATABASES = {
    "default": {
        "ENGINE": "django_psycopg_infinity.backends.postgresql",
        # ... other settings
    },
}

Then use DateTimeInfinityField in your models:

from django.db import models
from django_psycopg_infinity.fields import DateTimeInfinityField

class MyModel(models.Model):
    valid_until = DateTimeInfinityField(null=True, blank=True)

Usage

from datetime import datetime

# Store positive infinity
obj.valid_until = datetime.max
obj.save()

# Or use the string representation
obj.valid_until = "infinity"
obj.save()

# Retrieve - always returns an aware datetime
obj.refresh_from_db()
assert obj.valid_until.replace(tzinfo=None) == datetime.max

Development

Tests require a running PostgreSQL instance:

cp .env.example .env   # edit as needed
uv run runtests.py

Releasing

Releases are published to PyPI automatically when a version tag is pushed. The CI runs the full test suite before publishing.

Create a new release on GitHub with a v-prefixed tag (e.g. v0.1.0) and the workflow handles the rest.

Versioning is derived from git tags via hatch-vcs, so there are no version strings to update manually.

License

Apache-2.0

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_psycopg_infinity-0.1.0.tar.gz (11.6 kB view details)

Uploaded Source

Built Distribution

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

django_psycopg_infinity-0.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file django_psycopg_infinity-0.1.0.tar.gz.

File metadata

  • Download URL: django_psycopg_infinity-0.1.0.tar.gz
  • Upload date:
  • Size: 11.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for django_psycopg_infinity-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e004e8d55991dd733e4abb844466e3daeb6f2a50b298457f7462bd20198d400c
MD5 e2b10ec53602e5c3d4014c8025b78170
BLAKE2b-256 ff6291e11de1501fed49e9f76174d610bff2717bb5d8071abe9c86824f72a94f

See more details on using hashes here.

File details

Details for the file django_psycopg_infinity-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_psycopg_infinity-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for django_psycopg_infinity-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26fb2584f1748067e1b9ef8182cbe21d9211abdaf1fd22739ab77948dae7f9ab
MD5 9ed0164b19493a50bd33ee2bc13a60fe
BLAKE2b-256 7182dbf21af8274b31a08f856225d74ff47bd4c0866e14bf97596d9dfb38b618

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