All Projects → panosl → django-currencies

panosl / django-currencies

Licence: BSD-3-Clause license
django-currencies allows you to define different currencies, and includes template tags/filters to allow easy conversion between them.

Programming Languages

python
139335 projects - #7 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to django-currencies

Money bot
Docker-containered bot. Added to a group chat, she replies to any message containing price and currency pattern. Live!
Stars: ✭ 8 (-91.01%)
Mutual labels:  currencies
Node Currency Swap
Currency Exchange Rates library for nodejs
Stars: ✭ 119 (+33.71%)
Mutual labels:  currencies
hdx-python-country
Utilities to map between country and region codes and names and to match administrative level names from different sources. Also utilities for foreign exchange enabling obtaining current and historic FX rates for different currencies
Stars: ✭ 16 (-82.02%)
Mutual labels:  currencies
Exchange
Php script works with currenries.
Stars: ✭ 21 (-76.4%)
Mutual labels:  currencies
Javamoney Lib
JavaMoney financial libraries, extending and complementing JSR 354
Stars: ✭ 104 (+16.85%)
Mutual labels:  currencies
Nodamoney
NodaMoney provides a library that treats Money as a first class citizen and handles all the ugly bits like currencies and formatting.
Stars: ✭ 144 (+61.8%)
Mutual labels:  currencies
Countries
Countries, Languages & Continents data (capital and currency, native name, calling codes).
Stars: ✭ 656 (+637.08%)
Mutual labels:  currencies
MPNumericTextField
A class that extends UITextField to input numbers, percentages and currencies.
Stars: ✭ 18 (-79.78%)
Mutual labels:  currencies
Currency
Handles currency calculations, storage etc
Stars: ✭ 109 (+22.47%)
Mutual labels:  currencies
Prices
Python price handling for humans.
Stars: ✭ 248 (+178.65%)
Mutual labels:  currencies
Cldr
Internationalize your application using Unicode's CLDR
Stars: ✭ 38 (-57.3%)
Mutual labels:  currencies
Countries
Countries - ISO 3166 (ISO3166-1, ISO3166, Digit, Alpha-2 and Alpha-3) countries codes and names (on eng and rus), ISO 4217 currency designators, ITU-T E.164 IDD calling phone codes, countries capitals, UN M.49 regions codes, ccTLD countries domains, IOC/NOC and FIFA letters codes, VERY FAST, NO maps[], NO slices[], NO init() funcs, NO external links/files/data, NO interface{}, NO specific dependencies, Databases/JSON/GOB/XML/CSV compatible, Emoji countries flags and currencies support, full support ISO-3166-1, ISO-4217, ITU-T E.164, Unicode CLDR and ccTLD standarts.
Stars: ✭ 85 (-4.49%)
Mutual labels:  currencies
Cash Cli
💰💰 Convert currency rates directly from your terminal!
Stars: ✭ 168 (+88.76%)
Mutual labels:  currencies
Livecoin Api
LiveCoin RESTful API wrapper for Node.js
Stars: ✭ 12 (-86.52%)
Mutual labels:  currencies
BitBlocks old
BitBlocks Project_OLD
Stars: ✭ 12 (-86.52%)
Mutual labels:  currencies
Gocurrency
Simple currency converter. Insert an amount, what currency to convert from and what currency to convert to.
Stars: ✭ 26 (-70.79%)
Mutual labels:  currencies
Django Prices
Django fields for the prices module
Stars: ✭ 135 (+51.69%)
Mutual labels:  currencies
Nager.Country
Worldwide Country Informations (ISO-3166-1 Alpha2, ISO-3166-1 Alpha3, ISO 639-1)
Stars: ✭ 68 (-23.6%)
Mutual labels:  currencies
latinum
Latinum is a framework for resource and currency calculations.
Stars: ✭ 109 (+22.47%)
Mutual labels:  currencies
Fixer
A foreign exchange rates and currency conversion API
Stars: ✭ 2,545 (+2759.55%)
Mutual labels:  currencies

django-currencies

https://travis-ci.org/panosl/django-currencies.svg?branch=master

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

  1. Either clone this repository into your project, or install with pip:

    pip install django-currencies
  2. 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',
        )
  3. Either have the currencies.context_processors.currencies processor:

    TEMPLATE_CONTEXT_PROCESSORS += (
        'django.core.context_processors.request',  # must be enabled
        'currencies.context_processors.currencies',
    )
  4. Or use the template tag currency_context:

    {% load currency %}
    {% currency_context %}
  5. Update your urls.py file :

    urlpatterns += patterns('',
        url(r'^currencies/', include('currencies.urls')),
    )

Then run ./manage.py migrate to create the required database tables

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, Yahoo Finance and Currency ISO.

Management Commands

You can use the management commands currencies and updatecurrencies to maintain the currencies in the database. The former will import any currencies that are defined on the selected source into the database. This includes information like the currency code, name, symbol, and any other info provided. The latter will update all the database currency rates from the source. Any currency missing on the source will be untouched.

You can selectively import currencies, for example the commands below will import USD and EUR currencies only, or use a variable from the settings that points to an iterable respectively:

./manage.py currencies --import=USD --import=EUR
./manage.py currencies -i SHOP_CURRENCIES

The command automatically looks for variables CURRENCIES or SHOP_CURRENCIES in settings if -i is not specified. For more information on the additional switches --force and --verbosity try ./manage.py help currencies.

updatecurrencies can automatically change the base rate of the imported exchange rates by specifying the --base switch like so:

./manage.py updatecurrencies oxr --base=USD
./manage.py updatecurrencies yahoo -b SHOP_DEFAULT_CURRENCY

The command automatically looks for variables CURRENCIES_BASE or SHOP_DEFAULT_CURRENCY in settings if -b is not specified.

OpenExchangeRates

This is the default source or select it specifically using oxr as positional argument to either command.

You will need to specify your API key in your settings file:

OPENEXCHANGERATES_APP_ID = "c2b2efcb306e075d9c2f2d0b614119ea"

Requirements: requests (python3-compatible fork of OpenExchangeRatesClient is integrated due to abandoned project)

Yahoo Finance

Attention!

Yahoo integration is now deprecated due to withdrawal of the service around 6 Feb 2018 due to purchase by Verizon. The cached currency json file will continue to be available through the currencies command however.

Select this source by specifying yahoo as positional argument.

Requirements: BeautifulSoup4 and requests

Currency ISO

Select this source by specifying iso as positional argument.

Requirements: requests

Integration Live Feeds
  Currencies Rates Symbols Other Info
oxr *  
yahoo
iso    
* Symbols are imported from the file currencies.json because it is not
supported by the service. Other info includes ISO4217 number and exponent,
country and city names, and alternative currency names.

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] %}

or use the template tag currency_context:

{% currency_context %}

which gives the three context variables: CURRENCIES, CURRENCY_CODE and CURRENCY.

Template

Included is a template for a Bootstrap 3 & fontawesome compatible navbar currency chooser. The navbar item will display if there are more than 1 active currencies. There is a navbar parameter dropdown_extra_class which is used to supply extra classes to the dropdown:

{% block navbar-nav %}
    ...
    <ul class="nav navbar-nav navbar-right">
        ...
        {% with dropdown_extra_class="collapsed-nav" %}
        {% include "currencies/navbar/currency-chooser-bs3fa.html" %}
        {% endwith %}

Attention!

The currency choice may not be reflected on the navbar if your view is not re-rendered. This may be the case if you are viewing a default page in Django CMS for example. This is due to the context processor not being triggered because the RequestContext is not re-generated.

License

django-currencies is released under the BSD license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].