Skip to main content

A Django app to work with Iranian currency.

Project description

🏷️ Toman Display Template Tags for Django

A simple Django template tag library to render integers as Persian currency strings, converting numbers into Persian digits and formatting values with appropriate units like "هزار", "میلیون", and "میلیارد".

✨ Features

  • Converts integer values to human-readable Persian currency format.
  • Supports Persian digit conversion (e.g., 123۱۲۳).
  • Handles values in billions, millions, thousands, and ones.
  • Appends a customizable postfix (default: تومان).
  • Gracefully handles invalid or missing input.

🚀 Installation

Just drop the Python file into one of your Django app's templatetags/ directories.

For example:

myapp/
├── templatetags/
│   └── toman_display.py

Make sure your app is listed in INSTALLED_APPS in your settings.py.


🧠 Available Filters

toman_display

Formats numbers using Persian digits and currency breakdown.

Example:

{{ 12500000|toman_display }}

Output:

۱۲ میلیون و ۵۰۰ هزار تومان

With custom postfix:

{{ 12500000|toman_display:"ریال" }}

Output:

۱۲ میلیون و ۵۰۰ هزار ریال

toman_display_summary

This filter is defined but currently not implemented in the provided code. You can extend it to provide a short summary format if needed (e.g., only the largest unit, like "۱۲ میلیون").


to_persian_digits (internal helper)

Converts standard digits to Persian numerals.

to_persian_digits(123456)  # Output: '۱۲۳۴۵۶'

🧪 Error Handling

If a non-numeric or invalid value is passed, the output defaults to:

۰ تومان

📄 License

MIT – Feel free to use and modify.

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.2.0.tar.gz (3.2 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.2.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_persian_currency-0.2.0.tar.gz
  • Upload date:
  • Size: 3.2 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.2.0.tar.gz
Algorithm Hash digest
SHA256 b6ea60afad4d7bc0a96f8b9a8ca2da314ae9cf6985e7a08482c218fe165125c5
MD5 35a3edd1ebf93287ede8be417afc3b58
BLAKE2b-256 aee84b2d1656c118da4d9db1e4c62d16bc7139ef652dae8cf27ed4be400474fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_persian_currency-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c9896fcf2d32e88033cbc5ae4c8dd66aed047f2e9f4fc1a9047c052f48b26b1
MD5 509097844cf9ecec979c9994c6872e3f
BLAKE2b-256 43ed05ad2be7a1da6a25b531234008b25ab1162e9e868715321e1011b6ee7332

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