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.

Template filter

{% load djalaali_tags %}

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

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.0.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.0.0
File Size Uploaded Provenance Actions
djalaali-1.0.0.tar.gz 30.0 kB With provenance Details for djalaali-1.0.0.tar.gz

Built distributions (wheels)

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

Total release size: 349.9 kB

Release files / djalaali-1.0.0.tar.gz

Download URL djalaali-1.0.0.tar.gz
Size 30.0 kB
Tags Source
SHA-256 checksum
How to use checksums
520de5533fc753c49073d21bafeb0f826b9e26191680b1e32c9bce4dce814b7b
BLAKE2b-256 checksum
How to use checksums
4bad15690905518bd3f3c6ad0eba97a43767c79bc6151ec39580c67ee11d86ce
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.0.0-cp39-abi3-win_arm64.whl

Download URL djalaali-1.0.0-cp39-abi3-win_arm64.whl
Size 31.2 kB
Tags CPython 3.9 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
41484926b8a0e796e17b745d2dc0a9f98c71ae8a1bdbd9b88aabbff9ad5d162a
BLAKE2b-256 checksum
How to use checksums
cf051def99d2cfbc9a7509c357624dbd0ee607c80cad027f340d2df8984a0e30
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.0.0-cp39-abi3-win_amd64.whl

Download URL djalaali-1.0.0-cp39-abi3-win_amd64.whl
Size 31.6 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
bc62104daebd89f586b2a951cd5b07feafa41bcadc5868a0792941e4aab1779e
BLAKE2b-256 checksum
How to use checksums
b3151f72adb869327c6588f2c3c60dea4e507e0f6c0d277f233fceaf8c5d399a
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.0.0-cp39-abi3-win32.whl

Download URL djalaali-1.0.0-cp39-abi3-win32.whl
Size 31.2 kB
Tags CPython 3.9 Windows x86-32 abi3
SHA-256 checksum
How to use checksums
fcc82420e26ef3a99525dbd1e3149e718aa845fa4456b1b82de911d3356eed19
BLAKE2b-256 checksum
How to use checksums
b67a28a5bd660a5f7b5a5a9f597c17efe148bc3fea2a0f8c0ade0d33034abbce
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.0.0-cp39-abi3-musllinux_1_2_x86_64.whl

Download URL djalaali-1.0.0-cp39-abi3-musllinux_1_2_x86_64.whl
Size 40.7 kB
Tags CPython 3.9 Linux musl 1.2+ x86-64 abi3
SHA-256 checksum
How to use checksums
034c0a378762362f09991dcf84e272935eea230fe44b2bf742d332d210763c89
BLAKE2b-256 checksum
How to use checksums
bd3fd2cef784ec8e1a335ca450e5dd869fbfaef0d0fa870eccc88fc5940fd3e9
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.0.0-cp39-abi3-musllinux_1_2_aarch64.whl

Download URL djalaali-1.0.0-cp39-abi3-musllinux_1_2_aarch64.whl
Size 42.0 kB
Tags CPython 3.9 Linux musl 1.2+ ARM64 abi3
SHA-256 checksum
How to use checksums
fe3499a51d70a7929c30e7d1995cb3e3618336770fc787dea63841c0ed554df8
BLAKE2b-256 checksum
How to use checksums
6cc77b1a587870a05cb7562a0a55e6995032876fd9d9027488f64636c6aeb527
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.0.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl

Download URL djalaali-1.0.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Size 42.3 kB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
8432a04b9b9287295ea413cd7839d61249fcffbafe48c0dd53e8cf521db9d58a
BLAKE2b-256 checksum
How to use checksums
f36281b01584fc06bfc7b16db58a427cf931508f5900499142a54d1af4e76b13
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.0.0-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl

Download URL djalaali-1.0.0-cp39-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Size 40.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
55a585eeb265534b6e95da8b2bc16ae41c1b50983daed424edaed0228377cc95
BLAKE2b-256 checksum
How to use checksums
557d2a10377f3a1bc89bc555406a5fa21cc3091b2d54d8a6d9f42cd984917d59
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.0.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL djalaali-1.0.0-cp39-abi3-macosx_11_0_arm64.whl
Size 30.4 kB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c1a4cdfa77b6a2cc6b23ef64eeece62ae9a36396fb56401d502f411c747c45be
BLAKE2b-256 checksum
How to use checksums
8de6b12a3f57fe265227b79a50e0fe60bfe9d0ad0f7ffc4eb398f13d6dc5c25f
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.0.0-cp39-abi3-macosx_10_9_x86_64.whl

Download URL djalaali-1.0.0-cp39-abi3-macosx_10_9_x86_64.whl
Size 30.0 kB
Tags CPython 3.9 abi3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
f24c98dc65da77a2d9d3546f35e57a012783bf45a1de4289a6370ce75940d00f
BLAKE2b-256 checksum
How to use checksums
9ffa1c2f9c31ace89a645981d1cf8e2f83554cce9144c8f6f61e7dab187f48e5
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.0.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.0.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