基于django的货币兑换应用程序与xe datafeed api同步。
django-xe-currencies的Python项目详细描述
快速启动:
安装django xe货币:
$ pip install django-xe-currencies
将tinymce和xe_货币添加到settings.py中的已安装应用 您的项目:
INSTALLED_APPS = ( ... 'xe_currencies', )
将xe_currences.url添加到项目的url.py:
urlpatterns = patterns('', ... url(r'^currencies/', include('xe_currencies.urls')) )
在设置中指定xe_datafeed_url.py:
XE_DATAFEED_URL = 'http://www.xe.com/dfs/datafeed2.cgi?xeuser'
要与xe datafeed同步,请运行:
python manage.py xe_sync
在下一个url上访问api:
http://yourdomain.com/currencies/api/v1/currencies/exchange/?from=EUR&to=USD&amount=100&format=json
此示例将以json格式返回交换数据:
{"from": "EUR", "to": "USD", "result": "143.45 USD"}
要检索货币列表,请使用:
http://example.com/currencies/api/v1/currencies/?format=json
在代码中使用Exchange:
from xe_currencies.api.resources import exchange exchange('EUR', 'USD', 100)