Skip to main content

Currency conversion for money

Project description

https://badge.fury.io/py/django-money-rates.png https://travis-ci.org/evonove/django-money-rates.png?branch=master https://coveralls.io/repos/evonove/django-money-rates/badge.png https://pypip.in/d/django-money-rates/badge.png

Currency conversion for money

Documentation

The full documentation is at http://django-money-rates.rtfd.org.

Quickstart

Install django-money-rates:

pip install django-money-rates

Then use it in a project:

import djmoney_rates

In order to save exchange rates to your database, add djmoney_rates to your INSTALLED_APPS in your project’s settings:

INSTALLED_APPS = (
    ...
    'djmoney_rates',
    ...
)

Setup the Open Exchange Rates backend

Open an account at https://openexchangerates.org/ if you don’t have one already. Then, add this to your project’s settings:

DJANGO_MONEY_RATES = {
    'DEFAULT_BACKEND': 'djmoney_rates.backends.OpenExchangeBackend',
    'OPENEXCHANGE_URL': 'http://openexchangerates.org/api/latest.json',
    'OPENEXCHANGE_APP_ID': 'YOUR APP ID HERE',
    'OPENEXCHANGE_BASE_CURRENCY': 'USD',
}

For more information on the Open Exchange Rates API, see https://openexchangerates.org/

Pull the latest Exchange Rates

Once your backend is setup, get the latest exchange rates:

$ ./manage.py update_rates

Convert from one currency to another

Here’s an example of converting 10 Euros to Brazilian Reais:

from moneyed import Money from djmoney_rates.utils import convert_money brl_amount = convert_money(10, “EUR”, “BRL”) brl_money = Money(brl_amount, “BRL”)

Features

  • Convert money from one currency to another with an easy to use API.

TODO List

  • Add money converter wrapper for util’s convert_money function.

  • Add celery periodic task for getting daily exchange rates.

History

0.3.0 (2013-12-30)

  • convert_money utility function now returns moneyed.Money instances

0.1.0 (2013-10-16)

  • First release on PyPI.

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-money-rates-0.3.0.tar.gz (9.1 kB view details)

Uploaded Source

File details

Details for the file django-money-rates-0.3.0.tar.gz.

File metadata

File hashes

Hashes for django-money-rates-0.3.0.tar.gz
Algorithm Hash digest
SHA256 c32047143af8726ea21bb956d42918cd8f87ad4e7b9f76b63326968df7e2f317
MD5 24b85f137300cd7ef0a14cc8f98482c5
BLAKE2b-256 7b583a91b41daaf346514872988d4cd27cfdbb35309960aebd36f68580cd8906

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page