skillfed

django-pglocks

DEPRECATED — consolidated into django-pgware. Context managers for PostgreSQL advisory locks in Django.

django-pglocks v2.1.0 130.3K downloads/30d#11,645 on PyPI111
Permissive license MIT Active released

What it is and what it does

django-pglocks wraps PostgreSQL advisory locks as Django context managers, allowing you to protect critical sections of code from concurrent access using database-level locking. It was originally designed to serialize operations across multiple application instances without explicit distributed locking infrastructure.

As of version 2.1.0, this package is deprecated and serves only as a compatibility shim. Its functionality has been consolidated into django-pgware, which provides the same advisory_lock and async_advisory_lock exports under a different import path. The package will not receive further updates; it exists only to ease migration for existing users.

Use it for:

  • Migrate legacy code from django-pglocks to django-pgware by installing 2.1.0 as an intermediate step and addressing deprecation warnings.
  • Protect critical database operations from concurrent execution across multiple Django application instances using PostgreSQL locks.
  • Serialize access to shared resources (e.g., file uploads, report generation) without deploying a separate distributed lock service.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides PostgreSQL advisory locks for Django applications through context managers; deprecated and replaced by django-pgware.

No. This package is deprecated and explicitly directs users to django-pgware. Install django-pgware directly instead. If you have existing code using django-pglocks, version 2.1.0 can serve as a temporary bridge to ease migration, but it should not be the final destination—update your imports to use django-pgware's django_pg_utils module.

Install

django-pglocks on PyPI

pip

pip install django-pglocks

uv

uv add django-pglocks

poetry

poetry add django-pglocks

Installing django-pglocks

Before you install

Low friction to install, but the package is explicitly deprecated and no longer maintained. Version 2.1.0 is a final compatibility shim that re-exports from django-pgware with deprecation warnings; new projects should use django-pgware directly.

License in practice

MIT license permits commercial and private use with minimal restrictions, making it suitable for most projects—though this is moot given the package's deprecated status.

Quickstart

pip install django-pglocks

from django_pglocks import advisory_lock

with advisory_lock('my_lock_name'):
    # Critical section protected by PostgreSQL advisory lock
    pass

Requires Django and PostgreSQL; Python 3.10 or later.

Verify before relying

  • Whether existing code using django-pglocks will continue to work without modification after the deprecation period ends.
  • Performance characteristics of advisory locks under high concurrency in the underlying django-pgware implementation.

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 2 — django-pgware, django
Maintenance actively maintained — 54 days since the last release
Last repo commit
First released
Downloads 130,280/month — #11,645 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: django_pglocks-2.1.0-py3-none-any.whl

Development Status :: 7 - InactiveEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.0Framework :: Django :: 5.1Framework :: Django :: 5.2Intended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Software Development

Tags

postgresql advisory locks djangopostgres lock context managerdjango database lockingpostgresql concurrent access controldjango pgware migration
deprecatedpostgresql-locksmigration-shim

More Software Development packages

typing-extensions

Provides backported and experimental type hints…

permissive · top 100 on PyPI

numpy

NumPy provides an N-dimensional array object…

permissive · top 100 on PyPI

fastapi

FastAPI is a Python web framework for building…

permissive · top 100 on PyPI

annotated-doc

Provides a way to document function parameters,…

permissive · top 100 on PyPI

typer

Typer builds command-line applications from…

permissive · top 1,000 on PyPI

distlib

Distlib provides low-level packaging utilities…

permissive · top 1,000 on PyPI

django-pglock

Provides Postgres advisory locks, table locks,…

permissive · top 5,000 on PyPI

django-pg-zero-downtime-migrations

Provides a Django database backend for…

permissive · top 15,000 on PyPI

django-pgmigrate

Prevents migration downtime by detecting and…

permissive · top 5,000 on PyPI

django-postgres-copy

Provides Django ORM integration for…

permissive · top 5,000 on PyPI

django-waffle

Django Waffle provides feature flags (toggles)…

permissive · top 5,000 on PyPI

PyMySQLLock

Provides distributed locking primitives backed…

permissive · top 15,000 on PyPI

django-concurrency

Adds optimistic locking to Django models to…

permissive · top 15,000 on PyPI

django-dirtyfields

Tracks which fields on a Django model instance…

permissive · top 15,000 on PyPI

django-citext

Provides PostgreSQL CIText field types for…

permissive · top 15,000 on PyPI

django-constance

Django-constance lets you store and manage…

permissive · top 5,000 on PyPI