Metadata-Version: 2.4
Name: django-birthday
Version: 0.2.0
Summary: Helper field and manager for working with birthdays
Author-email: Jonas Obrist <ojiidotch@gmail.com>
Maintainer-email: Basil Shubin <basil.shubin@gmail.com>
License-Expression: BSD-3-Clause
Project-URL: download, https://github.com/bashu/django-birthday/zipball/master
Project-URL: homepage, https://github.com/bashu/django-birthday/
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 5.2
Classifier: Framework :: Django :: 6.0
Classifier: Framework :: Django :: 6.1
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.10
Description-Content-Type: text/x-rst
License-File: LICENSE
License-File: AUTHORS
Requires-Dist: django>=5.2
Dynamic: license-file

django-birthday
===============

.. image:: https://badge.fury.io/py/django-birthday.svg
    :target: https://badge.fury.io/py/django-birthday

.. image:: https://img.shields.io/pypi/pyversions/django-birthday.svg
    :target: https://pypi.python.org/pypi/django-birthday/

.. image:: https://img.shields.io/pypi/djversions/django-birthday.svg
    :target: https://pypi.python.org/pypi/django-birthday/

.. image:: https://github.com/bashu/django-birthday/actions/workflows/test.yml/badge.svg
    :target: https://github.com/bashu/django-birthday/actions/workflows/test.yml

django-birthday is a helper library to work with birthdays in models.

Maintained by `Basil Shubin <https://github.com/bashu/>`_,  and some great
`contributors <https://github.com/bashu/django-birthday/contributors>`_.

Installation
------------

First install the module, preferably in a virtual environment. It can be installed from PyPI:

.. code-block:: bash

    pip install django-birthday

Usage
-----

django-birthday provides a ``birthday.fields.BirthdayField`` model
field type which is a subclass of ``django.db.models.DateField`` and
thus has the same characteristics as that. It also internally adds a
second field to your model holding the day of the year for that
birthday, this is used for the extra functionality exposed by
``birthday.managers.BirthdayManager`` which you should use as the
manager on your model.

A model could look like this:

.. code-block:: python

    from django.db import models
    from django.conf import settings

    from birthday import BirthdayField, BirthdayManager


    class UserProfile(models.Model):
        user = models.ForeignKey(settings.AUTH_USER_MODEL)
        birthday = BirthdayField()

        objects = BirthdayManager()

Get all user profiles within the next 30 days:

.. code-block:: python

    UserProfile.objects.get_upcoming_birthdays()

Get all user profiles which have their birthday today:

.. code-block:: python

    UserProfile.objects.get_birthdays()

Or order the user profiles according to their birthday:

.. code-block:: python

    UserProfile.objects.order_by_birthday()

For more details, see the documentation_ at Read The Docs.

Contributing
------------

If you like this module, forked it, or would like to improve it, please let us know!
Pull requests are welcome too. :-)

Credits
-------

`django-birthday <https://github.com/bashu/django-birthday/>`_ was originally started by `Jonas Obrist <https://github.com/ojii>`_ who has now unfortunately abandoned the project.

License
-------

``django-birthday`` is released under the BSD license.

.. _documentation: https://django-birthday.readthedocs.io/

Changes
-------

0.2.0 (2026-08-14)
~~~~~~~~~~~~~~~~~~

* Dropped support for Python < 3.10 and Django < 5.2; migrated packaging
  from ``setup.py``/``setup.cfg`` to ``pyproject.toml``.
* Added an automatic ``post_migrate`` handler that backfills the cached
  day-of-year column for pre-existing rows and rows written via
  ``bulk_create()``/``update()`` whose value was never computed, so
  ``BirthdayManager`` queries are correct without manual intervention (#5).
* Fixed the cached day-of-year column being computed from each date's own
  actual year, which made it inconsistent for the same calendar day across
  leap and non-leap years and caused ``BirthdayManager`` to silently miss
  or misorder matching birthdays (#8). Day-of-year is now always computed
  relative to a fixed reference year, independent of leap status.
