Giter Site home page Giter Site logo

singular-labs / django-currencies Goto Github PK

View Code? Open in Web Editor NEW

This project forked from panosl/django-currencies

0.0 6.0 1.0 124 KB

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

Home Page: http://pypi.python.org/pypi/django-currencies

License: BSD 3-Clause "New" or "Revised" License

Python 97.38% HTML 2.62%

django-currencies's Introduction

django-currencies

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. 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',
    )
  4. 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.

django-currencies's People

Contributors

bashu avatar panosl avatar ngutman avatar bmihelac avatar dhendo avatar ronshub avatar einarf avatar strycore avatar ydaniv avatar zhangziang avatar yuvallehman avatar stelzzz avatar noxan avatar ipablo avatar singularvlad avatar davej avatar cxong avatar bagamsingular avatar

Watchers

James Cloos avatar Omri Ildis avatar Shahal Meril avatar Ron Konigsberg avatar  avatar  avatar

Forkers

yuvallehman

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.