Skip to content

Instantly share code, notes, and snippets.

@spookylukey
Created May 28, 2014 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spookylukey/eb6029bc48ab8410227b to your computer and use it in GitHub Desktop.
Save spookylukey/eb6029bc48ab8410227b to your computer and use it in GitHub Desktop.
How not to do currency exchange...
def exchange(self, price):
#default = Currency.objects.get(iso4217=DEFAULT_CURRENCY)
try:
rate = self.exchangerate_set.all()[0]
return Decimal(str(float(rate.denominator) * float(price)))
except IndexError:
return price
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment