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

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_persian_currency-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 e38a63370f2f88573f8f43b74318478e4d09a8c6e8fe8fe3c56ef90a27a853d5
MD5 dcebc5373df1e8f577494681d7e30bfb
BLAKE2b-256 d658b30acb5b1f8bf355609555882ba5cf36f9ecf50fb3cd8b5c220c8aaa876d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_persian_currency-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b8143163810aaa85b6a220b12ccce8d8b4255aff9608613bca5942f86a69e1ff
MD5 c485d423aae0a3d5b3942560cb219dd1
BLAKE2b-256 284a3e91aac11a02f0f48e59ee848e45efb8b1b94ca044f463c9e61d2f49d9b4

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