Skip to main content

A Django app to work with Iranian currency.

Project description

Django Persian Currency

A simple Django template tag for formatting Iranian currency values (تومان) into human-readable formats like:

  • 1,000,0001 میلیون تومان
  • 500,000500 هزار تومان
  • 123,456123,456 تومان

✨ Features

  • Converts raw integers into میلیارد, میلیون, or هزار تومان where appropriate
  • Falls back to comma-separated تومان when not divisible
  • Safe default for invalid input
  • Optional support for Persian digits (you can easily enable it)

🚀 Installation

pip install django_persian_currency

Add 'django_persian_currency' to your INSTALLED_APPS in settings.py:

INSTALLED_APPS = [
    ...
    'django_persian_currency',
]

🛠 Usage

In any Django template, first load the template tags:

{% load toman_filters %}

Then use the format_toman filter:

{{ 1000000|format_toman }}  {# Output: 1 میلیون تومان #}
{{ 725500|format_toman }}   {# Output: 725,500 تومان #}
{{ 500000|format_toman }}   {# Output: 500 هزار تومان #}

🧪 Testing

You can test it inside a Django shell:

python manage.py shell
from django.template.defaultfilters import register
from django_persian_currency.templatetags.toman_filters import format_toman

format_toman(1500000)  # Output: '1 میلیون تومان'

🤝 Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

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_persian_currency-0.1.2.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_persian_currency-0.1.2-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file django_persian_currency-0.1.2.tar.gz.

File metadata

  • Download URL: django_persian_currency-0.1.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.14

File hashes

Hashes for django_persian_currency-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c25c0b5917f9e407a0393d8a7b54777e785c87451d2a9cbcdef71446b9472f62
MD5 d2558995331cca89c3f295e1531203bf
BLAKE2b-256 0f7a1247f8c8d9af1fac00cf37128dc4e6e81d61629aa078696b38000c52c864

See more details on using hashes here.

File details

Details for the file django_persian_currency-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_persian_currency-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9e1398cfad0b5df8b8e4c2c40a07937256ff758a5bab781f5b851bd2aa1d1e49
MD5 eec48d7f6a079785e1dc2bdb08081282
BLAKE2b-256 37796b6eb1231853004a499a937a7e3a0f46ae8b8678cc079fe5b0660eeafab1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page