django-sequences
Generate gapless sequences of integer values.
Decision gist · record as of 2026-08-14
Yes, if you need gapless sequences for compliance or operational reasons. The package is stable (Production/Stable classifier), has no known vulnerabilities, and integrates cleanly into Django with minimal friction. The aging maintenance status is not a blocker—the code is mature and the last commit is recent. The serialization trade-off is acceptable for most accounting and invoicing workloads where sequence calls are infrequent relative to overall transaction volume.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Django 3.2+ and Python 3.8+.
- Guarantees apply only when get_next_value is called and its return value is saved to the database within the same transaction.
- Low friction install with a single runtime dependency on django.
License · maintenance · safety
BSD-3-Clause (permissive) — Released under BSD-3-Clause, a permissive open-source license. You may use, modify, and distribute the package freely in both commercial and private projects with minimal restrictions.
last release 2024-01-31 (926 days) · last repo commit 2026-01-05 · 246 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 253,098 downloads/mo, #8,527 on PyPI
Alternatives
Verify before relying
pip install django-sequences
# Add to INSTALLED_APPS: "sequences.apps.SequencesConfig"
# Run: django-admin migrate
from django.db import transaction
from sequences import get_next_value
with transaction.atomic():
Invoice.objects.create(number=get_next_value("invoice_numbers"))- Performance impact of transaction serialization on high-concurrency workloads with many sequences.
- Whether the nowait=True parameter bug mentioned in the docs affects real-world usage patterns.
What it is and what it does
django-sequences solves a compliance problem in Django applications: by default, Django's auto-incrementing primary keys can have gaps when transactions roll back, because most databases don't roll back their sequence counters for performance reasons. This happens on PostgreSQL, MySQL/MariaDB, Oracle, and SQLite. For use cases like accounting or invoicing where sequential, gapless numbering is legally or operationally required, these gaps are unacceptable.
The package provides a get_next_value function and a Sequence class that generate gapless integer sequences by leveraging database transaction integrity. You call get_next_value within a transaction, save its return value to the database in the same transaction, and the package guarantees no gaps. It supports multiple independent sequences, custom starting values, and looping sequences. The trade-off is that transactions calling get_next_value for the same sequence are serialized—other callers block until the transaction completes—so you should keep such transactions short.
Use it for
- Generate invoice numbers that must be sequential and gapless for accounting compliance and audit trails.
- Create sequential case or ticket IDs in support systems where gaps would confuse users or violate reporting requirements.
- Produce sequential receipt or order numbers in point-of-sale or e-commerce systems with strict numbering policies.
- Maintain gapless sequence counters for regulatory or financial reporting where auditors expect continuous numbering.
- Batch-generate a range of sequential IDs for bulk operations using get_next_values while preserving transaction guarantees.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need gapless sequences for compliance or operational reasons.
The package is stable (Production/Stable classifier), has no known vulnerabilities, and integrates cleanly into Django with minimal friction. The aging maintenance status is not a blocker—the code is mature and the last commit is recent. The serialization trade-off is acceptable for most accounting and invoicing workloads where sequence calls are infrequent relative to overall transaction volume.
Install
django-sequences on PyPI
Before you install
Low friction install with a single runtime dependency on django. Maintenance status is aging—last release was 2024-01-31 and last commit 2026-01-05—but the repository remains active and unarchived with 246 stars.
Requires Django 3.2+ and Python 3.8+. Guarantees apply only when get_next_value is called and its return value is saved to the database within the same transaction.
License in practice
Released under BSD-3-Clause, a permissive open-source license. You may use, modify, and distribute the package freely in both commercial and private projects with minimal restrictions.
Quickstart
pip install django-sequences
# Add to INSTALLED_APPS: "sequences.apps.SequencesConfig"
# Run: django-admin migrate
from django.db import transaction
from sequences import get_next_value
with transaction.atomic():
Invoice.objects.create(number=get_next_value("invoice_numbers"))
Verify before relying
- Performance impact of transaction serialization on high-concurrency workloads with many sequences.
- Whether the nowait=True parameter bug mentioned in the docs affects real-world usage patterns.
Package facts
| License | BSD-3-Clause permissive |
| Python support | Supports the current Python release >=3.8 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagedjango |
| Maintenance | Aging 926 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 253,098 / month, #8,527 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 3.2Framework :: Django :: 4.0Framework :: Django :: 4.1Framework :: Django :: 4.2Framework :: Django :: 5.0Intended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9 |
Evidence: django_sequences-3.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “gapless sequence generation django”
- django-sequencesProvides gapless sequence generation for Django models, ensuring no…
- django-ordered-modelAdds ordering and reordering capabilities to Django models, with…
- django-sortedm2mProvides a drop-in replacement for Django's ManyToManyField that…
Give your agent the search over MCP, or paste the wish link into any chat.
More Database packages
psycopg2-binary is a PostgreSQL database adapter for Python that implements the DB API 2.0 specification, enabling Python applications to connect to and query PostgreSQL databases with thread-safe concurrent operations.
Python client library for connecting to and executing commands against Redis key-value stores, supporting both synchronous and asynchronous operations.
Install it if your application needs to interact with Redis; the only prerequisite is a running Redis server instance.
YDB Python SDK is the official client library for connecting to and querying YDB databases from Python applications.
Install it if you need to connect Python applications to YDB databases.
Connects Python applications to Snowflake data warehouses using the DB API 2.0 specification, enabling SQL queries, data transfers, and warehouse operations.
sqlparse tokenizes SQL text into a tree of statements, clauses, and expressions, and provides functions to split scripts, format queries, and inspect parsed tokens without validating dialect or syntax.
Install it if you need to manipulate, format, or analyze SQL text programmatically.
Provides base adapter protocols and shared functionality that database adapters use to integrate with dbt-core, handling connections, dialect translation, relation caching, and core interface management.
See also django-fernet-fields-v2 · django-db-connection-pool · django-add-default-value · django-pgmigrate · SQLAlchemy-JSONField · djfernet · django-cleanup · django-safedelete · fractional-indexing · django-dirtyfields