🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

django-lastdayofmonth

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

django-lastdayofmonth

Cross-database LastDayOfMonth function for Django ORM

1.1.0
PyPI
Maintainers
1

django‑lastdayofmonth

PyPI PyPI - Python Version CI License: MIT

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 versionPython versionSupported back‑ends
3.2 LTS → 5.2 LTS3.8 → 3.12SQLite, 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.

Keywords

django

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts