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.
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
File details
Details for the file django-prices-openexchangerates-1.1.0.tar.gz
.
File metadata
- Download URL: django-prices-openexchangerates-1.1.0.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d8d31c988dc42e9a90621eded3cef71de255bb6071aef942390bbd88edd4640 |
|
MD5 | 75c9f8c2c7be9a22e70e6fe995c239c8 |
|
BLAKE2b-256 | 9b5932b1c80662ad57237e07d9a81f438b634cdfc2a9b5d8d92a8d96485e3c24 |
File details
Details for the file django_prices_openexchangerates-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: django_prices_openexchangerates-1.1.0-py3-none-any.whl
- Upload date:
- Size: 22.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8a8e85020ab62071bec29bf48eb7e688822141291e9d855b045efe1ab27ea74 |
|
MD5 | dd19e1807f1882e3bcdfeed84d067d11 |
|
BLAKE2b-256 | 2f91f51d0f60b34f35335137a523a2d71422df275b3a4b69fadda4f36b1f795f |