Adds support for multiple currencies as a Django application.
Project description
django-currencies allows you to define different currencies, and includes template tags/filters to allow easy conversion between them.
For more details, see the documentation at Read The Docs.
Authored by Panos Laganakos, and some great contributors.
Installation
Either clone this repository into your project, or install with pip:
pip install django-currencies
You’ll need to add currencies to INSTALLED_APPS in your project’s settings file:
import django INSTALLED_APPS += ( 'currencies', ) if django.VERSION < (1, 7): INSTALLED_APPS += ( 'south', )
Be sure you have the currencies.context_processors.currencies processor:
TEMPLATE_CONTEXT_PROCESSORS += ( 'django.core.context_processors.request', # must be enabled 'currencies.context_processors.currencies', )
Update your urls.py file :
urlpatterns += patterns('', url(r'^currencies/', include('currencies.urls')), )
Then run ./manage.py syncdb to create the required database tables
Please see example application. This application is used to manually test the functionalities of this package. This also serves as a good example.
You need Django 1.4 or above to run that. It might run on older versions but that is not tested.
Upgrading from 0.3.3
Upgrading from 0.3.3 is likely to cause problems trying to apply a migration when the tables already exist. In this case a fake migration needs to be applied:
./manage.py migrate currencies 0001 --fake
Configuration
django-currencies has built-in integration with openexchangerates.org.
You will need to specify your API key in your settings file:
OPENEXCHANGERATES_APP_ID = "c2b2efcb306e075d9c2f2d0b614119ea"
You will then be able to use the management commands currencies and updatecurrencies. The former will import any currencies that are defined on openexchangerates.org. You can selectively import currencies, for example bellow command will import USD and EUR currencies only:
./manage.py currencies --import=USD --import=EUR
The updatecurrencies management command will update all your currencies against the rates returned by openexchangerates.org. Any missing currency will be left untouched.
Usage
First of all, load the currency in every template where you want to use it:
{% load currency %}
Use:
{% change_currency [price] [currency_code] %}
for example:
{% change_currency product.price "USD" %}
<!-- or if you have the ``currencies.context_processors.currencies`` available -->
{% change_currency product.price CURRENCY.code %}
or use the filter:
{{ [price]|currency:[currency_code] }}
for example:
{{ product.price|currency:"USD" }}
or set the CURRENCY_CODE context variable with a POST to the included view:
{% url 'currencies_set_currency' [currency_code] %}
License
django-currencies is released under the BSD license.
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.