Helper field and manager for working with birthdays
django-birthday is a helper library to work with birthdays in models.
pip install django-birthday
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 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:
Get all user profiles which have their birthday today:
Or order the user profiles according to their birthday:
For more details, see the documentation at Read The Docs.
django-birthday is released under the BSD license.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for django_birthday-0.1.4-py3-none-any.whl