Skip to content
πŸŽ‚ django-birthday is a helper library to work with birthdays in models
Branch: develop
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
birthday
docs
.gitignore
.travis.yml
AUTHORS added AUTHORS Jan 20, 2017
LICENSE
MANIFEST.in
README.rst
setup.py
test_settings.py

README.rst

django-birthday

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

Authored by Jonas Obrist, and some great contributors.

Installation

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:

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

import birthday


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

    objects = birthday.managers.BirthdayManager()

Get all user profiles within the next 30 days:

UserProfile.objects.get_upcoming_birthdays()

Get all user profiles which have their birthday today:

UserProfile.objects.get_birthdays()

Or order the user profiles according to their birthday:

UserProfile.objects.order_by_birthday()

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

License

django-birthday is released under the BSD license.

You can’t perform that action at this time.