openexchangerates.org support for django-prices
Project description
openexchangerates.org support for django-prices
from prices import Money
from django_prices_openexchangerates import exchange_currency
converted_price = exchange_currency(Money(10, currency='USD'), 'EUR')
print(converted_price)
# Money('8.84040', currency='EUR')
It will also create additional steps if it cannot convert directly:
from prices import Money
from django_prices_openexchangerates import exchange_currency
converted_price = exchange_currency(Money(10, currency='GBP'), 'EUR')
print(converted_price)
# Money('13.31313588062401085236264978', currency='EUR')
The exchange_currency supports Money, TaxedMoney, MoneyRange and TaxedMoneyRange.
Template filters can be used with django-prices to convert currency, round amounts and display localized amounts in templates:
{% load prices_i18n %}
{% load prices_multicurrency %}
<p>Price: {{ foo.price.gross|in_currency:'USD'|amount }} ({{ foo.price.net|in_currency:'USD'|amount }} + {{ foo.price.tax|in_currency:'USD'|amount }} tax)</p>
Installation
First install the package:
pip install django-prices-openexchangerates
Then add 'django_prices_openexchangerates' to your INSTALLED_APPS.
Set following settings in your project's settings:
-
OPENEXCHANGERATES_API_KEY -
OPENEXCHANGERATES_BASE_CURRENCY(defaults to'USD', only premium accounts support other bases)
Use your admin console to create ConversionRate objects for each currency that you want to support.
Updating exchange rates
Fetch current rates from API with ./manage.py update_exchange_rates
Schedule this task in cron job or in celery, to be always up to date with exchange rates
You can use --all flag in above command, to create exchange rates automatically for all available currencies.
Crafted with ❤️ by Mirumee Software
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_prices_openexchangerates-1.3.0.tar.gz.
File metadata
- Download URL: django_prices_openexchangerates-1.3.0.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d44a74edda5b3fc7db666b0bf437eaa5b2e7ca135a8f5d7752ed389a76d54aa
|
|
| MD5 |
309f5f838597025ebe91e51669f13c48
|
|
| BLAKE2b-256 |
1578c3080f3faa5e64343105119903239070bd64e82fe107d4e129397fa50cdd
|
Provenance
The following attestation bundles were made for django_prices_openexchangerates-1.3.0.tar.gz:
Publisher:
publish.yml on mirumee/django-prices-openexchangerates
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_prices_openexchangerates-1.3.0.tar.gz -
Subject digest:
8d44a74edda5b3fc7db666b0bf437eaa5b2e7ca135a8f5d7752ed389a76d54aa - Sigstore transparency entry: 655662909
- Sigstore integration time:
-
Permalink:
mirumee/django-prices-openexchangerates@0052fab10f048650e2eec0d402c06f7a8e35377f -
Branch / Tag:
refs/tags/1.3.0 - Owner: https://github.com/mirumee
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0052fab10f048650e2eec0d402c06f7a8e35377f -
Trigger Event:
release
-
Statement type:
File details
Details for the file django_prices_openexchangerates-1.3.0-py3-none-any.whl.
File metadata
- Download URL: django_prices_openexchangerates-1.3.0-py3-none-any.whl
- Upload date:
- Size: 23.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2bc3f8f01cba9dcb864c3a0f1ce3ee59b4baa1d8aea3ab273f5e482c5dfc67ae
|
|
| MD5 |
865ea9b40f406197d9240c7432df098a
|
|
| BLAKE2b-256 |
0eade2d94a195426cc192d9643446b29f4a3d83c712f472a543441624666ccdb
|
Provenance
The following attestation bundles were made for django_prices_openexchangerates-1.3.0-py3-none-any.whl:
Publisher:
publish.yml on mirumee/django-prices-openexchangerates
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_prices_openexchangerates-1.3.0-py3-none-any.whl -
Subject digest:
2bc3f8f01cba9dcb864c3a0f1ce3ee59b4baa1d8aea3ab273f5e482c5dfc67ae - Sigstore transparency entry: 655662919
- Sigstore integration time:
-
Permalink:
mirumee/django-prices-openexchangerates@0052fab10f048650e2eec0d402c06f7a8e35377f -
Branch / Tag:
refs/tags/1.3.0 - Owner: https://github.com/mirumee
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0052fab10f048650e2eec0d402c06f7a8e35377f -
Trigger Event:
release
-
Statement type: