Registry / web-framework / django-money

django-money

JSON →
library3.6.1pypypi✓ verified 23d ago

Django Money is a little Django app that integrates the `py-moneyed` library to add robust support for money and currency fields in Django models and forms. It ensures accurate handling of monetary values, currency conversions, and formatting. The current version, 3.6.0, supports modern Django and Python versions and is actively maintained with regular releases.

pip install django-money
INSTALL
IMPORT
SIG · DJANGO-MONEY
D
django-money
web-frameworkpythonv3.6.1
Install
4.1s avg
Import
Disk
100MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.6.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 99.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 4.1s · import 0.000s · 101MB
100MB installed
● package 100MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MoneyField
from djmoney.models.fields import MoneyField
from djmoney.models.fields import MoneyField

This quickstart demonstrates how to define a `MoneyField` in a Django model, create instances with `Money` objects, and perform basic queries. It also highlights the required `INSTALLED_APPS` entry and the use of localization settings for proper display. The template tag `money_localize` is conceptually shown for front-end rendering.

import os import django from django.conf import settings from django.db import models settings.configure( INSTALLED_APPS=[ 'djmoney', 'tests', ], DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}}, DEFAULT_CURRENCY='USD', USE_L10N=True, # Enable localization for formatting ) django.setup() from djmoney.models.fields import MoneyField from djmoney.money import Money class BankAccount(models.Model): balance = MoneyField(max_digits=14, decimal_places=2, default_currency='USD') # It's also possible to have a nullable MoneyField: # money = MoneyField(max_digits=10, decimal_places=2, null=True, default_currency=None) def __str__(self): return f"{self.balance} - {self.pk}" # Run migrations (simplified for quickstart) with open(os.devnull, 'w') as f: import sys _stdout = sys.stdout sys.stdout = f try: from django.core.management import call_command call_command('makemigrations', 'tests', verbosity=0, interactive=False) call_command('migrate', verbosity=0, interactive=False) finally: sys.stdout = _stdout # Create an account account = BankAccount.objects.create(balance=Money(100, 'USD')) print(f"Created account: {account}") # Querying expensive_accounts = BankAccount.objects.filter(balance__gt=Money(50, 'USD')) print(f"Accounts with balance > $50: {list(expensive_accounts)}") # Accessing amount and currency separately print(f"Account balance amount: {account.balance.amount}") print(f"Account balance currency: {account.balance.currency}") # Example of template tag usage (conceptual, as this is a console quickstart) # In a Django template: # {% load djmoney %} # <p>Current balance: {{ account.balance|money_localize }}</p>
Debug
Known issues
breakingWhen upgrading to `django-money` 3.x from older versions (e.g., 2.x or 0.x), several features have been removed or renamed. Specifically, `Money.decimal_places_display` and `CURRENCY_DECIMAL_PLACES_DISPLAY` settings were removed in version 3.0. Additionally, support for older Python (2.6, 3.2) and Django (1.4-1.7, 1.9, 2.2, 3.0, 3.1, 4.0) versions has been dropped in various 3.x releases.
fix
Review the official changelog and documentation for your specific upgrade path. Replace removed settings and update import paths (e.g., use `djmoney.money.Money` instead of `moneyed.Money`). Ensure your Django and Python versions meet the minimum requirements for `django-money` 3.x (Python >=3.7, Django 2.2, 3.2, 4.0, 4.1, 4.2 supported by 3.6.0).
affects: <3.0
deprecatedThe import path `from moneyed import Money` has been deprecated in favor of `from djmoney.money import Money`. Similarly, `djmoney.models.fields.MoneyPatched` was deprecated.
fix
Update all instances of `from moneyed import Money` to `from djmoney.money import Money`. Remove any usage of `MoneyPatched`.
affects: 0.12, 3.0
gotchaFor money calculations, always use Python's `Decimal` type via `djmoney.money.Money` objects instead of floating-point numbers (`float`). Floats can introduce precision errors crucial for financial data.
fix
Perform all monetary operations using `Money` objects, which internally rely on `Decimal`. For direct arithmetic with amounts, ensure you convert to `Decimal` first if not already a `Money` object.
affects: All
gotchaTo ensure money fields are correctly displayed and integrated with Django's admin and localization features, you must add `'djmoney'` to your `INSTALLED_APPS` in `settings.py` and set `USE_L10N = True` for localization-aware formatting.
fix
Add `'djmoney'` to `INSTALLED_APPS` and `USE_L10N = True` in your Django `settings.py` file.
affects: All
gotchaWhen working with custom model managers on models containing `MoneyField`, you need to explicitly wrap your manager using `djmoney.models.managers.money_manager` to enable proper filtering and querying based on money values.
fix
Wrap your custom manager: `objects = money_manager(MyCustomManager())`.
affects: All
gotchaThe `MoneyField` internally stores two values (`amount` and `currency`). While ORM queries generally work with the `Money` object, direct database interactions or complex custom queries might require referencing the underlying `_amount` and `_currency` fields (e.g., `myfield_amount`, `myfield_currency`).
fix
Prefer ORM operations with `Money` objects. If direct database column access is needed, use the automatically generated `fieldname_amount` and `fieldname_currency` columns.
affects: All
Upgrade
Version history
3.6.1latest on PyPI · released Jun 7, 2026
Audit
Dependencies
py-moneyedrequiredProvides the core Money object and currency handling. Automatically installed as a dependency.
certifioptionalRequired for the `exchange` optional dependency for secure SSL connections to exchange rate APIs.
Agent activity
18 hits · last 30 days
node
16
Resources
django-money — pip install django-money · libregistry