Metadata-Version: 2.4
Name: rest-framework-money-field
Version: 3.1.0
Summary: A DRF serializer for monetary values.
Author-email: Rauli Laine <rauli.laine@treet.fi>
License-Expression: MIT
License-File: LICENSE
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.2
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: <4.0,>=3.10
Requires-Dist: django<6,>=4.2
Requires-Dist: djangorestframework-stubs[compatible-mypy]<4.0.0,>=3.16.8
Requires-Dist: djangorestframework<4.0.0,>3.7.0
Requires-Dist: py-moneyed<3.0,>=2.0
Description-Content-Type: text/markdown

# Money field for Django REST framework

[![pipeline status][pipeline-image]][pipeline-url]
[![coverage report][coverage-image]][coverage-url]
[![pypi][pypi-image]][pypi-url]

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:

```python
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:

```python
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:

```json
{
    "price": {
        "amount": 5000,
        "currency": "EUR"
    }
}
```

[django rest framework]: https://www.django-rest-framework.org/
[py-moneyed]: https://github.com/py-moneyed/py-moneyed
[dinero.js]: https://dinerojs.com/
[pipeline-url]: https://gitlab.com/treet/rest-framework-money-field/commits/master
[pipeline-image]: https://gitlab.com/treet/rest-framework-money-field/badges/master/pipeline.svg
[coverage-url]: https://gitlab.com/treet/rest-framework-money-field/commits/master
[coverage-image]: https://gitlab.com/treet/rest-framework-money-field/badges/master/coverage.svg
[pypi-url]: https://pypi.org/project/rest-framework-money-field
[pypi-image]: https://badge.fury.io/py/rest-framework-money-field.svg
