Skip to main content

django-currency-amount-field

Django's DecimalField has a UX trap in the admin: amounts are shown as a plain, ungrouped number, so a stray extra digit is invisible. Typing 10000000 instead of 1,000,000 looks almost identical to the eye and turns a million into ten million with no warning.

CurrencyField fixes this without asking you to build anything:

  • It's a drop-in DecimalField subclass, so it works with ModelForm, the admin, migrations, etc.
  • Its form widget groups digits with thousands separators as you type (via a small vanilla-JS file, no dependencies), so a typo is visually obvious immediately: 1,000,000 vs 10,000,000.
  • It automatically adds a sibling currency-code CharField to the model (default name <field>_currency), so an amount always carries its currency.

Install

pip install django-currency-amount-field

Add "currency_amount_field" to INSTALLED_APPS (needed for the static JS/CSS to be collected).

Usage

from django.db import models
from currency_amount_field.fields import CurrencyField


class Invoice(models.Model):
    total = CurrencyField(max_digits=12, decimal_places=2,
                                 default_currency="USD")

This generates two columns: total (the DecimalField) and total_currency (a CharField of ISO codes, defaulting to "USD").

No further admin configuration is required — ModelForm.formfield() picks up the comma-grouping widget automatically:

from django.contrib import admin


@admin.register(Invoice)
class InvoiceAdmin(admin.ModelAdmin):
    fields = ["total", "total_currency"]

Options

  • currency_field_name — override the sibling field's name.
  • default_currency — default value for the sibling field (e.g. "USD").
  • currency_choices — override the list of (code, label) choices (defaults to currency_amount_field.codes.CURRENCY_CHOICES, a common subset of ISO 4217).
  • currency_max_length — length of the currency-code column (default 3).

All other DecimalField arguments (max_digits, decimal_places, validators, etc.) work as usual.

How the formatting works

  • CurrencyWidget.format_value groups the stored decimal for display (1234567.89 → 1,234,567.89).
  • currency-widget.js re-groups the input live as the user types (including inside Django admin inline formsets added dynamically).
  • CurrencyFormField.to_python strips thousands separators before handing the value to DecimalField, so the grouped display never affects what gets saved.

Development

pip install -e ".[test]"
pytest

Metadata

Release files for django-currency-amount-field 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-currency-amount-field 1.0.0
File Size Uploaded Provenance Actions
django_currency_amount_field-1.0.0.tar.gz 9.9 kB With provenance Details for django_currency_amount_field-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-currency-amount-field 1.0.0
File Interpreter ABI Platform Actions
django_currency_amount_field-1.0.0-py3-none-any.whl Python 3 none any Details for django_currency_amount_field-1.0.0-py3-none-any.whl

Total release size: 19.4 kB

Release files / django_currency_amount_field-1.0.0.tar.gz

Download URL django_currency_amount_field-1.0.0.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1f0e41f33b9b7396f7a80df59c8ad34334a4d04bc6d4f592000ac905017b15d7
BLAKE2b-256 checksum
How to use checksums
afd5a8773721e91a8b2f0c28d728afe890c4e222851aca2eaa398b27eb122d7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release files / django_currency_amount_field-1.0.0-py3-none-any.whl

Download URL django_currency_amount_field-1.0.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba52d1aa3de6d575ae570cb0a24521b69abc9840e2d9b79c00d259f0cd642db0
BLAKE2b-256 checksum
How to use checksums
505152a9a81a7ccbed45ae7b8cfcd052d082eae1c8fddc473fe8a615c3ac7fb6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Security for django-currency-amount-field 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_currency_amount_field-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page