django-pglocks
DEPRECATED — consolidated into django-pgware. Context managers for PostgreSQL advisory locks in Django.
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-pglocksuv
uv add django-pglockspoetry
poetry add django-pglocksInstalling 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
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
django-pglockProvides Postgres advisory locks, table locks,…
permissive · top 5,000 on PyPI
django-pg-zero-downtime-migrationsProvides a Django database backend for…
permissive · top 15,000 on PyPI
django-pgmigratePrevents migration downtime by detecting and…
permissive · top 5,000 on PyPI
django-postgres-copyProvides Django ORM integration for…
permissive · top 5,000 on PyPI
django-waffleDjango Waffle provides feature flags (toggles)…
permissive · top 5,000 on PyPI
PyMySQLLockProvides distributed locking primitives backed…
permissive · top 15,000 on PyPI
django-concurrencyAdds optimistic locking to Django models to…
permissive · top 15,000 on PyPI
django-dirtyfieldsTracks which fields on a Django model instance…
permissive · top 15,000 on PyPI
django-citextProvides PostgreSQL CIText field types for…
permissive · top 15,000 on PyPI
django-constanceDjango-constance lets you store and manage…
permissive · top 5,000 on PyPI