Skip to main content

Django field for storing dates without years.

Project description

Provides a Django model and form fields for dates that do not include years.

One use case is to collect birthdays without requiring the year of birth.

Build status Python versions Django compatibility django-yearlessdate can be installed via wheel django-yearlessdate can be installed via wheel


  • Django 1.8 - 1.11, 2.0

  • Python 2.7, 3.6

(Other versions may function, but are untested.)


pip install django-yearlessdate


The package provides two model fields, YearlessDateField and YearField.


YearlessDateField stores a date without a year: January 1st, for example.

Its default widget consists of two dropdowns, one for a day and one for the month.

It will only allow potentially valid dates. For example, a user won’t be able to set the date to April 31st. February 29th is counted as a valid date.

Here’s an example that declares a model with a required yearless date:

from django.db import models
from djangoyearlessdate.models import YearlessDateField

class MyModel(models.Model):
    birthday = YearlessDateField()

The values of YearlessDateField on the model instances can be accessed like so:

>>> a = MyModel.objects.get(id=1)
>>> a
<MyModel: 4 August 2011>
>>> a.birthday.month
>>> print a.birthday
4 August

They can also be compared or sorted as would be expected, for example:

>>> m = MyModel.objects.all()
>>> m
[<MyModel: 4 August 2011>, <MyModel: 30 June 2013>]
>>> m[0].birthday > m[1].birthday
>>> m.order_by('birthday')
[<MyModel: 30 June 2013>, <MyModel: 4 August 2011>]


YearField is a very simple model field that stores the year as an integer, and ensures the year provided lies between 1900 and 2200:

from django.db import models
from djangoyearlessdate.models import YearField

class MyModel(models.Model):
    year = YearField(null=True, blank=True)

Use of YearField is not recommended due to its lack of configurability. You’re almost certainly better of using a SmallIntegerField in combination with a MinValueValidator and a MaxValueValidator.

Running tests


  1. Ensure you have a recent version of tox installed.

  2. Clone this repo.

Running tests

From the root of this repo, simply run:


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-yearlessdate-1.3.1.tar.gz (4.6 kB view hashes)

Uploaded Source

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