Skip to main content

A DRF serializer for monetary values.

Project description

Money field for Django REST framework

pipeline status coverage report pypi

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

rest-framework-money-field-2.0.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file rest-framework-money-field-2.0.0.tar.gz.

File metadata

  • Download URL: rest-framework-money-field-2.0.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.4 Linux/5.15.0-41-generic

File hashes

Hashes for rest-framework-money-field-2.0.0.tar.gz
Algorithm Hash digest
SHA256 19530226864b94359f5928f17856fe4fcae8ceeb6b4269140a7b444a47306b5d
MD5 dd9808efc223f3fb538932cf22463c8f
BLAKE2b-256 d7d2c100e4ee3694c5da3be6796f57282054eb85b3687e23717e21de121b4363

See more details on using hashes here.

File details

Details for the file rest_framework_money_field-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rest_framework_money_field-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 77c6ab5cf72051b86c3d6244850a5796cd2b13b164376c79fa5b7e6e9608e539
MD5 6294e039be7f30f95095a88831b80692
BLAKE2b-256 e8a1558c8ce95cd790556eeb6db920696692cd97cac47d0e1c37e1ade7690a43

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page