Git Product home page Git Product logo

django-metasettings's Introduction

django-metasettings

A reusable Django application to control the currency rate and favorite language code, inspired by etsy

First you need to request an app id at open exchange rates to import currency rates.

Installation

  1. To install it, simply

    pip install django-metasettings
    
  2. Add 'metasettings' to your INSTALLED_APPS

    INSTALLED_APPS = (
        'metasettings',
    )
    

If you want to install the dashboard to allow your users to select a language and a currency you will have to install urls from metasettings like so

# urls.py

from django.conf.urls import patterns, include

urlpatterns = patterns(
    '',
    (r'^', include('metasettings.urls'))
)

You can add your proper stylesheet to this dashboard view and have this kind of result:

http://cl.ly/image/2j0I3V1B0G1w/metasettings.png

Usage

To import current currency rates, run

python manage.py sync_rates --app_id=openexchangesratesappid

To import currency rates in a date range, run

python manage.py sync_rates --app_id=openexchangesratesappid --date_start=2011-10-01 --date_end=2013-10-01

It will import for each months between the two dates the currency rates.

If you can to convert an amount from on currency to another

from metasettings.models import convert_amount

convert_amount('EUR', 'USD', 15)  # ~20 euros

By default it will return a full decimal, if you want a converted integer

from metasettings.models import convert_amount

convert_amount('EUR', 'USD', 15, ceil=True)  # ~20 euros

To retrieve the currency with a client IP Address:

from metasettings.models import get_currency_from_ip_address

get_currency_from_ip_address('78.192.244.8') # EUR

We are using GeoIP which gives you the ability to retrieve the country and then we are linking the country to an existing currency.

So don't forget to import a fresh GeoIP database and be sure to have GEOIP_PATH in your settings.

We recommend to use django-geoip-utils which provides some helpers to manipulate GeoIP API.

django-metasettings's People

Contributors

thoas avatar

Watchers

James Cloos avatar Fabio Anderegg 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.