Skip to main content

A Django app to work with Iranian currency.

Project description

django-toman

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-toman

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

INSTALLED_APPS = [
    ...
    'django_toman',
]

🛠 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_toman.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.0.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.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_persian_currency-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 7e717044d4e5a446ff5227712d04233f646fb27e088531be5372969c789178f2
MD5 79680f60e9fa88aae64a9de516b4b722
BLAKE2b-256 a2fe8ee9cf6b15174e4f58c25dfd1818d413fba3ac376ed7b851a7a027684f37

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_persian_currency-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8eb94a29836a42e647adddfc8f8e42bc67a53f9f057a1095e5a1fa70fea9728f
MD5 1f673e04e35d0193cd1de7c4ddb3eedc
BLAKE2b-256 7a59106508ea779fde7719eac15883330a7c60335b478382993ed716495a4d22

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