Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bashu/django-birthday
🎂 django-birthday is a helper library to work with birthdays in models
https://github.com/bashu/django-birthday
birthdays django
Last synced: 2 months ago
JSON representation
🎂 django-birthday is a helper library to work with birthdays in models
- Host: GitHub
- URL: https://github.com/bashu/django-birthday
- Owner: bashu
- License: bsd-3-clause
- Created: 2010-09-27T19:03:57.000Z (over 14 years ago)
- Default Branch: develop
- Last Pushed: 2021-12-02T06:29:42.000Z (about 3 years ago)
- Last Synced: 2024-10-06T14:17:51.165Z (3 months ago)
- Topics: birthdays, django
- Language: Python
- Homepage: https://django-birthday.readthedocs.io/
- Size: 57.6 KB
- Stars: 24
- Watchers: 4
- Forks: 8
- Open Issues: 3
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
django-birthday
===============.. image:: https://img.shields.io/pypi/v/django-birthday.svg
:target: https://pypi.python.org/pypi/django-birthday/.. image:: https://img.shields.io/pypi/dm/django-birthday.svg
:target: https://pypi.python.org/pypi/django-birthday/.. image:: https://img.shields.io/github/license/bashu/django-birthday.svg
:target: https://pypi.python.org/pypi/django-birthday/.. image:: https://img.shields.io/travis/bashu/django-birthday.svg
:target: https://travis-ci.com/github/bashu/django-birthday/django-birthday is a helper library to work with birthdays in models.
Maintained by `Basil Shubin `_, and some great
`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 settingsfrom 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 `_ was originally started by `Jonas Obrist `_ who has now unfortunately abandoned the project.
License
-------``django-birthday`` is released under the BSD license.
.. _documentation: https://django-birthday.readthedocs.io/