django国家货币代码

Mav*_*ick 8 python django python-2.7 django-1.5 django-countries

django_countries用来显示国家列表.现在,我有一个要求,我需要根据国家显示货币.挪威 - 挪威克朗,欧洲和非洲(除英国外) - 欧元,英国 - 英镑,美国和亚洲 - 美元.

这可以通过django_countries项目实现吗?或者我可以使用python或django中的其他软件包吗?

任何其他解决方案也受到欢迎.

---------------------------更新-------------主要重点在于获得很多解决方案: Norway - NOK, Europe & Afrika (besides UK) - EUR, UK - GBP, AMERICAS & ASIA - USDs.

---------------------------- SOLUTION --------------------- -----------

我的解决方案很简单,当我意识到我无法获得任何ISO格式或包来获得我想要的东西时,我想编写自己的脚本.它只是一个基于条件的逻辑:

from incf.countryutils import transformations
def getCurrencyCode(self, countryCode):
        continent = transformations.cca_to_ctn(countryCode)
        # print continent
        if str(countryCode) == 'NO':
            return 'NOK'

        if str(countryCode) == 'GB':
            return 'GBP'

        if (continent == 'Europe') or (continent == 'Africa'):
            return 'EUR'

        return 'USD'
Run Code Online (Sandbox Code Playgroud)

不知道这是否有效,想听听一些建议.

感谢大家!

ale*_*cxe 13

那里有几个模块:

pycountry定期更新,py-moneyed看起来很棒,功能多python-money,python-money现在还没有维护.

希望有所帮助.