I use django_countries to show a list of countries. Now I have a requirement when I need to show the currency depending on the country. Norway - NOK, Europe and Africa (except Great Britain) - EUR, UK - GBP, AMERICAS and ASIA - USD.
Can this be achieved through the django_countries project? or are there other packages in python or django that I could use for this?
Any other solution is also welcome.
--------------------------- UPDATE ------------- The main emphasis is on this after receiving many decisions : Norway - NOK, Europe & Afrika (besides UK) - EUR, UK - GBP, AMERICAS & ASIA - USDs.
---------------------------- DECISION ------------------ --- -----------
My solution was pretty simple when I realized that I couldn’t get any ISO format or package to get what I want, I thought to write my own script. This is just conditional logic:
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'
I do not know if it is effective or not, I would like to hear some suggestions.
Thanks everyone!
Maverick
source share