Skip to main content

djalaali

build coverage python django

Jalali (Persian) calendar support for Django: jdate and jdatetime types, model and form fields, and template tags.

Install

pip install djalaali

Add "djalaali" to INSTALLED_APPS.

Usage

Dates and datetimes

jdate and jdatetime mirror the API of datetime.date and datetime.datetime.

import datetime
from djalaali.jdate import jdate
from djalaali.jdatetime import jdatetime

d = jdate(1403, 1, 1)
d = jdate.fromgregorian(datetime.date(2024, 3, 20))  # jdate(1403, 1, 1)
d.togregorian()                                      # datetime.date(2024, 3, 20)
d.isleap()                                           # True
d.isoformat()                                        # "1403-01-01"
d.strftime("%A %d %B %Y")                            # "چهارشنبه 01 فروردین 1403"

jdate.today()
jdate.fromisoformat("1403-01-01")
jdate.strptime("1403/01/15", "%Y/%m/%d")

d + datetime.timedelta(days=30)                      # jdate(1403, 1, 31)
d - jdate(1402, 12, 1)                               # datetime.timedelta(days=29)
d < jdate(1403, 2, 1)                                # True

t = jdatetime(1403, 1, 1, 13, 5)
t.togregorian()                                      # datetime.datetime(2024, 3, 20, 13, 5)
t.strftime("%Y/%m/%d %H:%M")                         # "1403/01/01 13:05"
jdatetime.now()

Dates outside the supported Jalali years (-61 to 3177) raise djalaali.algo.ErrorInvalidYear; invalid dates such as jdate(1403, 12, 31) raise ValueError.

Low-level conversion

from djalaali.algo import to_jalaali, to_gregorian, is_leap_year, month_length

to_jalaali(2024, 3, 20)    # (1403, 1, 1)
to_gregorian(1403, 1, 1)   # (2024, 3, 20)
is_leap_year(1403)         # True
month_length(1403, 12)     # 30

Conversions use a C extension when one is available and fall back to an identical pure-Python implementation otherwise (about 60x slower, same results). Check djalaali.algo.HAS_C_EXTENSION to see which is active, or set DJALAALI_PURE_PYTHON=1 to force the Python one.

Models, forms and admin

With "djalaali" in INSTALLED_APPS, every DateField and DateTimeField automatically gets a Jalali form field with a calendar picker, in ModelForms and in the admin. Values are still stored as Gregorian dates in the database.

from django.db import models
from djalaali.models import GregorianDateField


class Event(models.Model):
    title = models.CharField(max_length=100)
    date = models.DateField()                     # Jalali in forms and admin
    starts_at = models.DateTimeField(null=True)   # Jalali in forms and admin
    registered_on = GregorianDateField(null=True)  # opts out, stays Gregorian

Widgets or form classes you set explicitly (for example in Meta.widgets) are left alone. You can also use the fields directly in plain forms:

from django import forms
from djalaali.forms import JalaliDateField, JalaliDateTimeField, JalaliDateInput


class EventForm(forms.Form):
    date = JalaliDateField()
    starts_at = JalaliDateTimeField(required=False)
    # Optional overrides for the calendar widget labels:
    birthday = JalaliDateField(widget=JalaliDateInput(today_label="امروز"))

Render the form with {{ form.media }} in your template so the calendar's CSS and JavaScript are loaded.

Date formats

Settings mirror Django's DATE_FORMAT / DATE_INPUT_FORMATS family. Defaults are shown:

# Display (Django `date` filter syntax, like DATE_FORMAT): admin change list,
# read-only fields, and the `jdate` filter when used without an argument.
DJALAALI_DATE_FORMAT = "Y/m/d"
DJALAALI_DATETIME_FORMAT = "Y/m/d H:i"

# Form input parsing (strptime syntax, like DATE_INPUT_FORMATS), tried in order.
DJALAALI_DATE_INPUT_FORMATS = ["%Y/%m/%d", "%Y-%m-%d", "%Y.%m.%d"]
DJALAALI_DATETIME_INPUT_FORMATS = [
    "%Y/%m/%d %H:%M:%S", "%Y/%m/%d %H:%M",
    "%Y-%m-%d %H:%M:%S", "%Y-%m-%d %H:%M",
    "%Y.%m.%d %H:%M:%S", "%Y.%m.%d %H:%M",
]

As in Django, the first entry of DJALAALI_DATE_INPUT_FORMATS is how widgets render a value, and it also drives the placeholder and the calendar picker, so it may only use %Y, %m, %d and literal separators. The datetime widget has separate date and time inputs; their combined text is matched against DJALAALI_DATETIME_INPUT_FORMATS and against every date input format combined with %H:%M:%S or %H:%M. The time input itself is rendered as HH:MM:SS. input_formats= on JalaliDateField / JalaliDateTimeField overrides the settings.

Supported Django format characters: d j D l w z m n M F t L y Y a A g G h H i s u O e T c, with \ to escape. Others are output as-is.

The jdate filter argument uses the same syntax: {{ d|jdate:"j F Y" }}.

Template filter

{% load djalaali_tags %}

{{ event.date|jdate }}                      {# 1403/01/01 #}
{{ event.date|jdate:"d F Y" }}              {# 01 فروردین 1403 #}
{{ event.starts_at|jdate:"Y/m/d H:i" }}

Month and weekday names

Names come from JalaliConfig and can be changed globally, for example to use Latin transliterations:

from djalaali.jdate import JalaliConfig

JalaliConfig().months[1] = ("Farvardin", "Far")

A runnable example lives in demo/ (make demo).

Development

make install
make test

License

MIT

Metadata

Release files for djalaali 1.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 djalaali 1.1.0
File Size Uploaded Provenance Actions
djalaali-1.1.0.tar.gz 33.9 kB With provenance Details for djalaali-1.1.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for djalaali 1.1.0
File Actions
djalaali-1.1.0-cp39-abi3-win_arm64.whl CPython 3.9 abi3 Windows ARM64 Details for djalaali-1.1.0-cp39-abi3-win_arm64.whl
djalaali-1.1.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for djalaali-1.1.0-cp39-abi3-win_amd64.whl
djalaali-1.1.0-cp39-abi3-win32.whl CPython 3.9 abi3 Windows x86-32 Details for djalaali-1.1.0-cp39-abi3-win32.whl
djalaali-1.1.0-cp39-abi3-musllinux_1_2_x86_64.whl CPython 3.9 abi3 Linux musl 1.2+ x86-64 Details for djalaali-1.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
djalaali-1.1.0-cp39-abi3-musllinux_1_2_aarch64.whl CPython 3.9 abi3 Linux musl 1.2+ ARM64 Details for djalaali-1.1.0-cp39-abi3-musllinux_1_2_aarch64.whl
djalaali-1.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64, Linux glibc 2.28+ ARM64 Details for djalaali-1.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
djalaali-1.1.0-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl CPython 3.9 abi3 Linux glibc 2.5+ x86-64, Linux glibc 2.28+ x86-64 Details for djalaali-1.1.0-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
djalaali-1.1.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for djalaali-1.1.0-cp39-abi3-macosx_11_0_arm64.whl
djalaali-1.1.0-cp39-abi3-macosx_10_9_x86_64.whl CPython 3.9 abi3 macOS 10.9+ x86-64 Details for djalaali-1.1.0-cp39-abi3-macosx_10_9_x86_64.whl

Total release size: 380.9 kB

Release files / djalaali-1.1.0.tar.gz

Download URL djalaali-1.1.0.tar.gz
Size 33.9 kB
Tags Source
SHA-256 checksum
How to use checksums
39e06bee3e5419ffebebea719c067f219a899eb067321ea9084f8a4bd9ee5e62
BLAKE2b-256 checksum
How to use checksums
16ff917d0d1c0c8b5bdd8e6da8e87f223e9f5fd1e2c29546b062a69e4ffb1f53
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 10, 2026.

Transparency log

Release files / djalaali-1.1.0-cp39-abi3-win_arm64.whl

Download URL djalaali-1.1.0-cp39-abi3-win_arm64.whl
Size 34.2 kB
Tags CPython 3.9 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
307e791bca4e9ac8dc0f041030244bf87bdf45ea50c178303bc1cb7091c27d59
BLAKE2b-256 checksum
How to use checksums
cdc1cd7abbf55e159640f6b8e3c49837acee85a8c7cece48dea511628d547e39
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 10, 2026.

Transparency log

Release files / djalaali-1.1.0-cp39-abi3-win_amd64.whl

Download URL djalaali-1.1.0-cp39-abi3-win_amd64.whl
Size 34.6 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
dc7ecbf799c251ed3c251ab157c07659466139164e7662d7d8865d8733f7ffe3
BLAKE2b-256 checksum
How to use checksums
b516d1d6c360279227f414f357fb6920892eda5833f29e5384356fc92d1ed353
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 10, 2026.

Transparency log

Release files / djalaali-1.1.0-cp39-abi3-win32.whl

Download URL djalaali-1.1.0-cp39-abi3-win32.whl
Size 34.3 kB
Tags CPython 3.9 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
74e2cffc2c8b4c66a8e64fc3ec3b3b176e7e3cfed99c082b664545d5a1f4cf1c
BLAKE2b-256 checksum
How to use checksums
7c72e4a06c4b1fadfa92c3a6b8b50f464487c66185db38e9fdf402dccd7ad6b5
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 10, 2026.

Transparency log

Release files / djalaali-1.1.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL djalaali-1.1.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 43.7 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
5d36d2a44e3c8163275ec4b361b0cafb511e9670a2fe2d3427f069c91f9c98a1
BLAKE2b-256 checksum
How to use checksums
c280258e326b07e5c69db34e593477bd4a8c514c8181baaced87368511aa9886
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 10, 2026.

Transparency log

Release files / djalaali-1.1.0-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL djalaali-1.1.0-cp39-abi3-musllinux_1_2_aarch64.whl
Size 45.0 kB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
b0a8b231af8fab3c67233df24a2bba31d611dc9f48dde169fb871a7f86c4ab73
BLAKE2b-256 checksum
How to use checksums
e08c15393e07216fed6f4c4936fa50f358c89cb72edc691a77b5e70852e4fd8b
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 10, 2026.

Transparency log

Release files / djalaali-1.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL djalaali-1.1.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 45.3 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
473d789e1f20bb4ba0a9f953ec4c7b496978f241b085f0df535652ae588e8f70
BLAKE2b-256 checksum
How to use checksums
cb7f8eed8aaf9cbc114c1f3992fddd9430720b7b27daa42d9b59e935af9789fb
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 10, 2026.

Transparency log

Release files / djalaali-1.1.0-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL djalaali-1.1.0-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 43.6 kB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 abi3
SHA-256 checksum
How to use checksums
ef2c92634a7f756ad7e8b7a036dfc69b4cf92545777a96c28d484558b5ae80a7
BLAKE2b-256 checksum
How to use checksums
f3a5503e852e36f7cedc6e8c74d54c608126b400502e580a3fb7dc49c21bcedb
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 10, 2026.

Transparency log

Release files / djalaali-1.1.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL djalaali-1.1.0-cp39-abi3-macosx_11_0_arm64.whl
Size 33.4 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
3c364fc3d1058156ab1cf0d482fe4294bdb3a497017d01720772bca07170d3d8
BLAKE2b-256 checksum
How to use checksums
e2bc9bc24f075e6b26155b6311eadcb60cff842f9dfff1ddf873bd0ce131e00b
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 10, 2026.

Transparency log

Release files / djalaali-1.1.0-cp39-abi3-macosx_10_9_x86_64.whl

Download URL djalaali-1.1.0-cp39-abi3-macosx_10_9_x86_64.whl
Size 33.0 kB
Tags CPython 3.9 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
e4840cfef2bba2f077b29f936709c62921568178f82e4c82775d0336fb0edd4e
BLAKE2b-256 checksum
How to use checksums
6cbbcf8763354196342c7715e3145337cfc7186327d0b0d1943d16e192b6a916
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 10, 2026.

Transparency log

Security for djalaali 1.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

All 10 files in this release have been uploaded with provenance metadata.

Select from 10 files

Attestation for djalaali-1.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 10, 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.

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