Registry / ecommerce / django-prices

django-prices

JSON →
library2.4.0pypypi✓ verified 84d ago

Django fields for the `prices` module, providing model fields (MoneyField, TaxedMoneyField) and a price range field for use with Django models. Current version is 2.4.0, updated June 2024. It supports Python >=3.10 and Django >=3.2. Release cadence is maintenance mode, with occasional bug fixes.

pip install django-prices
INSTALL
IMPORT
SIG · DJANGO-PRICES
D
django-prices
ecommercepythonv2.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

MoneyField
from django_prices.models import MoneyField
Correct import for the Money model field
TaxedMoneyField
from django_prices.models import TaxedMoneyField
Correct import for TaxedMoneyField
satchless.contrib.django_prices.models.MoneyField
from satchless.contrib.django_prices.models import MoneyField
old location from v0.x; no longer available

Define a Django model with MoneyField and TaxedMoneyField, including default values. Ensure Django is configured before importing the model.

import os os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' import django django.setup() from django.db import models from django_prices.models import MoneyField, TaxedMoneyField from prices import Money, TaxedMoney class Product(models.Model): name = models.CharField(max_length=100) price = MoneyField(currency='USD', max_digits=10, decimal_places=2, default=Money('0', 'USD')) taxed_price = TaxedMoneyField(currency='USD', max_digits=10, decimal_places=2, default=TaxedMoney(Money('0', 'USD'), Money('0', 'USD'))) class Meta: app_label = 'test_app' # Creating an instance product = Product(name='Test', price=Money('10', 'USD'), taxed_price=TaxedMoney(Money('10', 'USD'), Money('1', 'USD'))) product.save()
Debug
Known issues
breakingDropped support for Python <3.10 and Django <3.2 in version 2.0. Upgrade if still on older versions.
fix
Ensure Python >=3.10 and Django >=3.2
affects: >=2.0
deprecatedThe 'currency' parameter in MoneyField is mandatory; omitting it will raise an error.
fix
Always specify currency='...' when declaring the field.
affects: >=2.0
gotchaDefault values must be proper 'prices' objects (Money or TaxedMoney), not Python numeric types. Using an integer or float will cause a TypeError.
fix
Use Money('10', 'USD') or TaxedMoney(...) as default.
affects: all
gotchaMigrations: If you change the currency on an existing MoneyField, you must manually create a migration to alter the column type (the library does not handle currency changes automatically).
fix
Create a migration with AlterField and update the currency manually.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'MoneyField' from 'django_prices'
Incorrect import path; users often try 'from django_prices import MoneyField' instead of from the models submodule.
fix
Use 'from django_prices.models import MoneyField'.
TypeError: 'int' object is not callable
Using a numeric default like default=0 instead of a Money object.
fix
Set default=Money('0', 'USD') or default=TaxedMoney(Money('0', 'USD'), Money('0', 'USD')).
AttributeError: 'NoneType' object has no attribute 'currency'
The field value is None but the code expects a Money object. Occurs when the field is nullable and not set.
fix
Ensure the field is not nullable or provide a default.
Upgrade
Version history
2.4.0latest on PyPI · released Oct 29, 2025
Audit
Dependencies
pricesrequiredcore library providing Money, TaxedMoney, etc.
Djangorequiredframework for model fields and migrations
Babeloptionaloptional for currency formatting
Agent activity
46 hits · last 30 days
node
40
Resources
django-prices — pip install django-prices · libregistry