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-money 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": 1000,
"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.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 597f0931b69f3759fd2f52d4dbcda6b90f7e0aca531196dd05cdda2f480170d1 |
|
MD5 | ef396a9c5a6bac360c012066baa35f10 |
|
BLAKE2b-256 | ee75df4619ee59dd81c47698884e5a7bd282e8771068be95e9590af821e90c0a |
Close
Hashes for rest_framework_money_field-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c07a2a723c0f9ea8b7095028afcd116e0ab76143be1b63074d78d0f110a144dd |
|
MD5 | 8af0acb11b3b83a95ccd33eed0f50dec |
|
BLAKE2b-256 | 25fb255ada67d0813b5e99f79f88ac60a9ec32a6898a8d53b341bdb84ce1dc56 |