Skip to main content

Django currency

Overview

Simple django app that handles basic currency handling, formatting and manual addition of exchange rates that can be used to easy convert from one currency to another

Example usage

from currency.models import Currency, ExchangeRate, Money

usd = Currency.objects.create(code='USD', short_name=u'$')
eur = Currency.objects.create(code='EUR', short_name=u'€')

ExchangeRate.objects.create(base_currency=usd, foreign_currency=eur, rate=1/1.3)

print(usd.get_rate(eur))  # Decimal('0.76923')
print(eur.get_rate(usd))  # Decimal('1.30000')

my_money = Money(1531, 'USD')
print(my_money)  # 1531.00000USD
my_money += Money(23, 'USD')
print(my_money)  # 1554.00000USD
print(my_money.convert_to('EUR'))  # 1195.38342EUR

# be careful with conversions. Errors accumulate with each conversion. Example:
print(my_money.convert_to('EUR').convert_to('USD'))  # 1553.99845USD


# indirect rates through rates of default currency (USD) are available too
hrn = Currency.objects.create(code='UAH', short_name='hrn')
rub = Currency.objects.create(code='RUB', short_name='rub')

ExchangeRate.objects.create(
    base_currency=default_currency, foreign_currency=hrn,
    rate='0.125')
# get stored value:
rate1 = ExchangeRate.objects.get(
    base_currency=default_currency, foreign_currency=hrn)

ExchangeRate.objects.create(
    base_currency=default_currency, foreign_currency=rub,
    rate='0.03125')
# get stored value:
rate2 = ExchangeRate.objects.get(
    base_currency=default_currency, foreign_currency=rub)

self.assertEqual(hrn.get_rate(rub), rate1.rate / rate2.rate)

Metadata

Release files for django-currency 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-currency 0.0.8
File Size Uploaded Provenance
django-currency-0.0.8.tar.gz 7.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-currency 0.0.8
File Interpreter ABI Platform
django-currency-0.0.8.linux-x86_64.tar.gz Details

Total release size: 23.8 kB

Release files / django-currency-0.0.8.tar.gz

Download URL django-currency-0.0.8.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4ca7003568a02b42ea83f5f0020b070371000b6fa3fc0b69de573d70fa3eb834
BLAKE2b-256 checksum
How to use checksums
807a46f7d6fee35ba6805e387ad1278161a431dc370c4a3266b7e295f26fba1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django-currency-0.0.8.linux-x86_64.tar.gz

Download URL django-currency-0.0.8.linux-x86_64.tar.gz
Size 16.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2e22a2ba8b56197122cdd284836488b68d5c9871384e446aa0ede8abd85bdf8c
BLAKE2b-256 checksum
How to use checksums
62e318690d3e7dc1cf0bb2805d77913f33db99321e9985535b48846eaf026d40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-currency 0.0.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.8 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page