Skip to main content

django-partial-dates

Tests Build Publish Coverage PyPI Development status Python Django Ruff Licence

A Django model field for dates that are known only to the year, to the month or to the day: 1990, 1990-06 or 1990-06-14. It stores a date at the precision it was recorded at, and never more.

Documentation: https://django-partial-dates.fairdm.org

Why

Research records are full of dates nobody knows exactly. A sample was collected "in 1990", a project started "in June 2014", an affiliation ended "some time in 2019". Django's DateField cannot hold any of these without inventing a day and a month, and once it has, nothing can tell the invented date from a recorded one.

Quickstart

The package is pre-alpha. It needs Python 3.12 or later, Django 5.2 or later, and PostgreSQL or SQLite.

$ pip install django-partial-dates

Declare the field on a model, then make and apply the migration.

from django.db import models

from partial_dates import PartialDateField


class Sample(models.Model):
    collected = PartialDateField(null=True, blank=True, db_index=True)
from partial_dates import PartialDate

Sample.objects.create(collected=PartialDate(1990, 6))
Sample.objects.filter(collected__month=6)

The first line stores 1990-06. The second finds every sample collected in a June, and leaves out samples whose month nobody recorded.

Features

Scope and philosophy

What it is:

  • A model field that stores a year, a year and month, or a full date in one database column.
  • A value type for those dates, which sorts, compares and hashes.
  • Lookups for filtering on them, and a form field and widget for editing them, in model forms and the admin as well as plain forms.

What it is not:

  • Not a date range. A partial date is one date whose day or month is unknown, not an interval with known ends.
  • Not a parser for free-text dates such as "spring 1990" or "c. 1850".
  • Not a full implementation of EDTF, the Extended Date/Time Format. Its three forms are EDTF level 0. Uncertain and approximate dates (1990?, 1990~) are outside its scope.

When two ways are possible:

  • Never store what was not recorded. A partial date is uncertain, and the database holds it as uncertain. A stored value never claims a day or a month nobody gave.
  • Uncertain in, uncertain out. Filters and lookups on partial dates inherit the uncertainty of the values. The package documents exactly what each one matches rather than hiding the question.
  • Standard forms over clever encodings. Values are stored in their ISO 8601 form, so any tool reading the database reads them correctly.

Prior art

This package replaces django-partial-date, which has had no release since January 2022. The prior art page compares the alternatives.

Licence

MIT. See LICENSE.

Metadata

Release files for django-partial-dates 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-partial-dates 0.1.0
File Size Uploaded Provenance Actions
django_partial_dates-0.1.0.tar.gz 20.5 kB With provenance Details for django_partial_dates-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-partial-dates 0.1.0
File Interpreter ABI Platform Actions
django_partial_dates-0.1.0-py3-none-any.whl Python 3 none any Details for django_partial_dates-0.1.0-py3-none-any.whl

Total release size: 46.0 kB

Release files / django_partial_dates-0.1.0.tar.gz

Download URL django_partial_dates-0.1.0.tar.gz
Size 20.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3987780f12d0ed3dd9db013411e463cc59926d3de49782da5fbf3e52a795af05
BLAKE2b-256 checksum
How to use checksums
f84da032ffb5855515c782b3526bc74ef5ec927dbe282a3ac67f7f10e98b927e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / django_partial_dates-0.1.0-py3-none-any.whl

Download URL django_partial_dates-0.1.0-py3-none-any.whl
Size 25.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
862203cb1b4a1b30da39a775fe301dba39287e95ca44d6db012abd6be2571cd5
BLAKE2b-256 checksum
How to use checksums
eade9ed7ef028f5edffdf64ef0ae2238cb68977dd285b4bf8df2b2e0f65566d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for django-partial-dates 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_partial_dates-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page