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.2.1.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

rest_framework_money_field-2.2.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file rest_framework_money_field-2.2.1.tar.gz.

File metadata

  • Download URL: rest_framework_money_field-2.2.1.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.3 Linux/6.8.0-48-generic

File hashes

Hashes for rest_framework_money_field-2.2.1.tar.gz
Algorithm Hash digest
SHA256 313c34e281ee8fed5f550d22bb487aae5ab7d63a1ab1570f71e672a9dbe29caa
MD5 4f0e1556322d387c9f4be5d96705897c
BLAKE2b-256 7931d62b28a80bbaed2736750a7f61bea1e65de2a9efb2060043d09a2b4f90b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rest_framework_money_field-2.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 da016ba6a50df3769f85e07fbf04377e3d9d0306f47ab359fab1d1d9f34c1fa5
MD5 05502cfa24b292ce00c1c4e57ee52001
BLAKE2b-256 099f7d637b55ef2fbcec8d868fd4a6886c076eea58fbc94b727c099ab419e937

See more details on using hashes here.

Supported by

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