A DRF serializer for monetary values.
Project description
Money field for Django REST framework
An serializer field implementation for Django REST framework that serializes monetary types provided by py-moneyed library. Serialized data is compatible with Dinero.js JavaScript library.
Usage example
For example, if you would have an serializer like this:
from rest_framework.serializers import Serializer
from rest_framework_money_field import MoneyField
class ProductSerializer(Serializer):
price = MoneyField()
And you would use the serializer with data like this:
from moneyed import Money
from rest_framework.renderers import JSONRenderer
serializer = ProductSerializer({"price": Money(50, "EUR")})
json = JSONRenderer().render(serializer.data)
You would end up with JSON like this:
{
"price": {
"amount": 5000,
"currency": "EUR"
}
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for rest-framework-money-field-1.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a65f2438d19384561e00c908abb6e4868fcab092048036e083563f45d46a860d |
|
MD5 | 62fd09f9f47b0da13538cef3db13a458 |
|
BLAKE2b-256 | 4773cd236df0cfae57be0fe431286a9a28a310f8a10e2da8c4b82ad10eb1ed41 |
Close
Hashes for rest_framework_money_field-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb49d0eafb007c4c2b27b7901b4b3d434fa75fb307519dc3f8a0b1949a64e332 |
|
MD5 | 023c60994207220848623e1e69de25ef |
|
BLAKE2b-256 | 40ec3460ed00e3b5331ec814e83bf677175f01e5f57ad96e77de937b7fa78c5b |