Skip to main content

Helper field and manager for working with birthdays

Project description

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

Authored by Jonas Obrist, and some great contributors.

https://img.shields.io/pypi/v/django-birthday.svg https://img.shields.io/pypi/dm/django-birthday.svg https://img.shields.io/github/license/bashu/django-birthday.svg https://img.shields.io/travis/bashu/django-birthday.svg

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

import birthday


class UserProfile(models.Model):
    user = models.ForeignKey('auth.User')
    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.

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

django-birthday-0.1.3.tar.gz (4.6 kB view hashes)

Uploaded source

Built Distribution

django_birthday-0.1.3-py3-none-any.whl (5.2 kB view hashes)

Uploaded 3 7

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page