Code Monkey home page Code Monkey logo

django-currencies's Introduction

Introduction

django-currencies allows you to define different currencies, and includes template tags/filters to allow easy conversion between them. Usage

Once you have everything set up (read the included INSTALL.txt and docs/), you will be able to use the following code in your templates:

{% change_currency [price] [currency_code] %}

# i.e:

{% change_currency product.price "USD" %}

# or if we have the currencies.context_processors.currencies
# available:

{% change_currency product.price CURRENCY.code %}

or use the filter:

{{ [price]|currency:[currency] }}

# i.e.:

{{ product.price|currency:"USD" }}

or set the CURRENCY context variable with a POST to the included view:

{% url currencies_set_currency [currency] %}

OpenExchangeRates integration

django-currencies has builtin 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 "initcurrencies" and "updatecurrencies". The former will create any currency that exists on openexchangerates.org with a default factor of 1.0. It is completely optional and does not require an API key. A list of currency codes may be supplied to limit the currencies that will be initialised.

The updatecurrencies management command will update all your currencies against the rates returned by openexchangerates.org. Any missing currency will be left untouched.

The updatecurrencysymbols command will add the currency symbol (if missing) to each currency present. Make sure that your symbol and name columns are set to UTF-8.

Source Code

The source is kept under git version control at https://github.com/panosl/django-currencies

You can get it by cloning the repository:

git clone git://github.com/panosl/django-currencies.git

Documentation

You can browse it online here: http://readthedocs.org/projects/django-currencies/

Running Tests

I'm using nose along with nosedjango

The settings.py is inside the tests/ directory, so you'll need to cd to it, and:

nosetests -v --with-django

django-currencies's People

Contributors

panosl avatar bmihelac avatar dhendo avatar strycore avatar ydaniv avatar davej avatar noxan avatar stelzzz avatar zhangziang avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.