Cross-database LastDayOfMonth function for Django ORM
Project description
django‑lastdayofmonth
Cross‑database LastDayOfMonth ORM function for Django.
Calculate the last calendar day of any month directly in the database, with the same API on SQLite, PostgreSQL, MySQL/MariaDB and Oracle.
Installation
pip install django-lastdayofmonth
That’s it — no settings tweaks required.
Simply import the helper wherever you need it (see Quick usage for an example).
Compatibility matrix
| Django version | Python version | Supported back‑ends |
|---|---|---|
| 3.2 LTS → 5.2 LTS | 3.8 → 3.12 | SQLite, PostgreSQL ≥ 12, MySQL ≥ 5.7 / MariaDB ≥ 10.4, Oracle ≥ 19c |
The library is fully tested in CI across all the combinations above.
Quick usage
from django.db.models import DateField
from django_lastdayofmonth import LastDayOfMonth
# annotate each invoice with the month‑end date of its `issued_date`
Invoice.objects.annotate(
month_end=LastDayOfMonth("issued_date")
)
LastDayOfMonth works in annotate(), filter(), aggregate(), etc.
Why?
Calculating month‑end boundaries in Python causes heavy data transfer and breaks query optimisations. Leveraging the database engine keeps logic in SQL and stays performant.
Running tests locally
pip install tox pytest pytest-django dj-database-url mysqlclient oracledb psycopg2-binary # install testing and DB driver dependencies
pytest -q --reuse-db # run tests locally
Use tox to run the full matrix (tox -p auto). See .github/workflows/ci.yml for Docker examples of each database.
License
Released under the MIT license. See the LICENSE file for details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_lastdayofmonth-1.1.0.tar.gz.
File metadata
- Download URL: django_lastdayofmonth-1.1.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
168e69ebd5eda5161eaa4533442cb2fcaff205a175a5d5e416ac87525d3c5cb1
|
|
| MD5 |
d54bd7917d8076fdb6b96758bde4f896
|
|
| BLAKE2b-256 |
6678546665c60a935dbda12ae7445e63e4c86cb1c41fdabd0b9470b50bec63d2
|
File details
Details for the file django_lastdayofmonth-1.1.0-py3-none-any.whl.
File metadata
- Download URL: django_lastdayofmonth-1.1.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12de0492b1edf78829a033ec79cb3c69e9504ef72827bbe0d2dd1dd35868091b
|
|
| MD5 |
bfb5632bf533c325efa7ac12618ff2bb
|
|
| BLAKE2b-256 |
ea937c1f994534494b9b08d0344d1f4b0d482a264194e842d03f201f925070ca
|