Simple app to manage currencies convertion in Django using [openexchangerates.org](https://openexchangerates.org) service.
The app will automatically invokes the service and in a **single HTTP call** it will creates all the necessary conversion rates permutations offline **by "bypassing" the free account limitation which limits the source currency to USD** using simple math alghoritms and the excellent Python's `itertools` utilities (so this is 100% legal!).
---
## Quick start
### Installation
1. Get an app key from [openexchangerates.org](https://openexchangerates.org) (you don't need to pay, the basic free account will be enough)
2. Add "django_easy_currencies" to your `INSTALLED_APPS` setting like this:
```
INSTALLED_APPS = (
...
'django_easy_currencies',
)
```
3. Configure the app by providing your app id and the currencies you want to use like this:
```
EASY_CURRENCIES = {
'currencies': (
('USD', 'US Dollar'),
('EUR', 'Euro'),
('GBP', 'British Pound'),
('AUD', 'Australian Dollar'),
('CAD', 'Canadian Dollar'),
('CHF', 'Swiss Franc'),
('JPY', 'Japanese Yen'),
),
'app_id': os.environ['EASY_CURRENCIES_APP_ID']
}
```
**Just a note**: *An environment variable holding your app id is a best practice but is not mandatory, you can define it inline in your settings.py*
4. Include the "**django_easy_currencies**" URLconf in your project urls.py like this:
```
url(r'^currency/', include('django_easy_currencies.urls')),
```
5. Add the "**django_easy_currencies**" context processor to your existent processors like this:
```
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as BASE_CONTEXT_PROCESSORS
TEMPLATE_CONTEXT_PROCESSORS = BASE_CONTEXT_PROCESSORS + (
'django_easy_currencies.context_processors.currency',
)
```
6. Run `python manage.py migrate` to create the app models.
7. Run the custom management command `python manage.py currencies --update` to save currency rates in your database.
*You should run this command at least once a day in order to have updated rates (automatization of this step is up to you)*
8. (Optional) Run `python manage.py currencies --list` to see the loaded currency rates
### Change active currency
The default currency automatically activated by the context porcessor is "**USD**".
To change it "**django_easy_currencies**" provides a custom tag which prints a combo with all the available currencies and calls `ChangeCurrencyView` as soon the user select a new option.
To use the tag you just need to:
1. Load the tag library:
`{% load currencies %}`
2. Use the tag:
`{% currencies_combo %}`
### Display localized currencies in templates
1. Load the tag library:
`{% load currencies %}`
2. Use the custom tag to display the converted price:
`{% local_currency original_price original_currency %}`
The tag will convert the `original_price` using `original_currency` into the currenct active currency (which is available in template context as "`active_currency`"). And formatting it with the right currency symbol.
So, supposing you are going to print a localized book price which originally is **39.50 USD **and the active currency is **EUR**, the result will be something like: **€ 31,26**.
And in the template it will looks like:
`{% local_currency book.price 'USD' %}`
or
`{% local_currency book.price book.original_currency %}`
It's also possible to skip number formatting by passing `False` as the third tag argument:
`{% local_currency book.price 'USD' False %}`
In this way the output will be simply: **31.26**
Metadata
Release files for django-easy-currencies 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-easy-currencies-0.1.1.tar.gz | 21.6 kB | Without provenance | Details for django-easy-currencies-0.1.1.tar.gz |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_easy_currencies-0.1.1-py2.7.egg | Legacy Egg format | - | - | Details for django_easy_currencies-0.1.1-py2.7.egg |
| django-easy-currencies-0.1.1.macosx-10.8-x86_64.exe | Details for django-easy-currencies-0.1.1.macosx-10.8-x86_64.exe |
Total release size: 154.4 kB
Release files / django-easy-currencies-0.1.1.tar.gz
| Download URL | django-easy-currencies-0.1.1.tar.gz |
|---|---|
| Size | 21.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
38bfb7ede8fab1dbc9d14d1f0dea807b69d21e3ad16b1edc59842b330bc95b85
|
|
BLAKE2b-256 checksum How to use checksums |
19e075e4daff7f310c38604c1d46a87483dc65f84dfd425b5f030a6ce3e71b05
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_easy_currencies-0.1.1-py2.7.egg
| Download URL | django_easy_currencies-0.1.1-py2.7.egg |
|---|---|
| Size | 34.8 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
c11e4144024360a090fec10939f83dda4906461f2eec1c19d12242b0da726fd0
|
|
BLAKE2b-256 checksum How to use checksums |
c1b1f9011abb481f7f82bfaab8d55825c9e3f672e4d9a2603ada80b9f91de172
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django-easy-currencies-0.1.1.macosx-10.8-x86_64.exe
| Download URL | django-easy-currencies-0.1.1.macosx-10.8-x86_64.exe |
|---|---|
| Size | 98.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5377aa16aebfb54c5d972ec7e0dd755a479ea0e87282b10a6f796f4677fd12c7
|
|
BLAKE2b-256 checksum How to use checksums |
a7e3353e24fc4a3569728de642b4bd41556b06ae27de3b32e4fa5cf9bbbe41a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-easy-currencies 0.1.1
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.