Created
May 2, 2020 18:45
-
-
Save yoandresaav/6d2346e62ba81c0bb0e84e277f0a72a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from djmoney.contrib.django_rest_framework import MoneyField | |
from moneyed import Money, Decimal | |
class MyMoneyField(MoneyField): | |
def to_representation(self, obj): | |
return { | |
'amount': "%f" % (obj.amount), | |
'currency': "%s" % (obj.currency), | |
} | |
def to_internal_value(self, data): | |
return Money(Decimal(data), 'THB') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment