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.1.tar.gz (3.5 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.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_persian_currency-0.2.1.tar.gz
  • Upload date:
  • Size: 3.5 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.1.tar.gz
Algorithm Hash digest
SHA256 77752426d520a5955aa736e8bf0d360f0b961367cecff62753b454af01f658fb
MD5 384f68972eb89576a2db46a265d2a51d
BLAKE2b-256 58e4a11a0a959e5c510b5e49f6bcab86dc5cb3192373463a5c9aed6f78a14a69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_persian_currency-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1139b90a43995dcff8a61c817b6791aae4256440fe06907f00c2bddb9af92f92
MD5 6e8380af2d9a6a33ce858652a1fdb269
BLAKE2b-256 4dd6e6b0ff0551781e722ef2551d8f991e5fdae7c87562a3ffa6ee6c27e59a52

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