Skip to content

angee.money.fields

Money-owned model fields.

MoneyField

python
class MoneyField(models.DecimalField)

A decimal amount paired with the currency its row is denominated in.

docs/stack.md keeps money native: a DecimalField (default max_digits=18, decimal_places=6), never a money library. The single fact a money column adds over a plain decimal is which currency the amount is in: currency_field names the path to the money addon's Currency foreign key that owns the row's currency, either a sibling FK on the same model ("currency", the default) or a one-hop related path ("order.currency") when the currency lives on a parent document.

currency_field is a semantic declaration, not a database fact: Django's Field.deconstruct serializes only the tracked column kwargs (the field's class path plus max_digits / decimal_places) and never a custom constructor attribute, so currency_field stays out of migration state on its own — no deconstruct override — while the currency path rides through deepcopy inheritance onto the live field. Changing currency_field therefore never writes a migration. Rendering the amount with its currency (resolved through the metadata's currency path) is the "money" widget's job, registered by the currency addon's web package; the field only owns the backend vocabulary.

__init__

python
def __init__(*args: Any,
             currency_field: str = "currency",
             **kwargs: Any) -> None

Record the currency path and default the money decimal precision.

angee_currency_field

python
@property
def angee_currency_field() -> str

Return the currency path this field declares for resource metadata.

check

python
def check(**kwargs: Any) -> list[checks.CheckMessage]

Validate that currency_field resolves to the money addon's Currency.

Released under the AGPL-3.0 License.