Wagtail integration for the UniRate currency-exchange API — StreamField blocks, Django template tags, and a cached client wired through Django settings.
Project description
wagtail-unirate
Wagtail + Django integration for the UniRate currency-exchange API. Drop currency rates, conversions, and multi-currency price tables straight into Wagtail page bodies; use template tags anywhere in Django templates.
- StreamField blocks:
CurrencyRateBlock,CurrencyConversionBlock,MultiCurrencyPriceBlock. - Template tags under
{% load unirate %}:unirate_rate,unirate_convert,unirate_to,unirate_format,unirate_currencies,unirate_historical_rate. - Cached lookups via Django's standard cache framework (opt-in via
UNIRATE_CACHE_TIMEOUT). - Wagtail 5.x / 6.x · Django 4.2 / 5.0 / 5.1 / 5.2 · Python 3.10–3.13.
- No new HTTP code: every network call goes through the official
unirate-apiPython client.
Install
pip install wagtail-unirate
Add to INSTALLED_APPS (after the wagtail.* apps):
INSTALLED_APPS = [
# …
"wagtail",
"wagtail_unirate",
]
Set your API key in settings.py or as an environment variable:
UNIRATE_API_KEY = os.environ["UNIRATE_API_KEY"]
Get a free key at https://unirateapi.com.
Settings
| Setting | Default | Description |
|---|---|---|
UNIRATE_API_KEY |
— | API key. Falls back to the UNIRATE_API_KEY env var. |
UNIRATE_BASE_URL |
https://api.unirateapi.com |
Override the API base (rare; testing or a self-hosted proxy). |
UNIRATE_TIMEOUT |
30 |
Per-request timeout in seconds. |
UNIRATE_CACHE_TIMEOUT |
0 (off) |
If positive, latest-rate / convert / supported-currency lookups are cached for this many seconds via Django's cache framework. |
UNIRATE_CACHE_ALIAS |
default |
The CACHES alias used when caching is enabled. |
UNIRATE_DEFAULT_BASE_CURRENCY |
USD |
Default base for the unirate_to template tag. |
Template tags
{% load unirate %}
Today's USD/EUR rate: {% unirate_rate "USD" "EUR" %}
100 USD ≈ {% unirate_convert 100 "USD" "EUR" %} EUR
A price of 9.99 in the configured base ≈
{% unirate_to 9.99 "JPY" %} JPY
{% unirate_format 1234.56 "EUR" %} {# → "1,234.56 EUR" #}
{% unirate_currencies as codes %}
Supported codes: {{ codes|join:", " }}
Historical (Pro plan):
{% unirate_historical_rate "USD" "EUR" "2025-01-15" %}
Every value-returning tag falls back silently to None (or [] for
unirate_currencies) on API errors so a third-party blip cannot break a
page render.
StreamField blocks
from wagtail import blocks
from wagtail.fields import StreamField
from wagtail_unirate.blocks import (
CurrencyConversionBlock,
CurrencyRateBlock,
MultiCurrencyPriceBlock,
)
class HomePage(Page):
body = StreamField(
[
("paragraph", blocks.RichTextBlock()),
("currency_rate", CurrencyRateBlock()),
("currency_conversion", CurrencyConversionBlock()),
("multi_currency_price", MultiCurrencyPriceBlock()),
],
use_json_field=True,
)
Editors then get three new blocks in the Wagtail page editor. Each block renders inline HTML and silently swallows API failures (it falls back to an empty fragment) so a transient blip never breaks the page.
Caching tip
Currency rates change slowly. A 5- to 15-minute cache window is usually plenty and removes virtually all per-request UniRate calls on a busy site:
UNIRATE_CACHE_TIMEOUT = 600 # 10 minutes
License
MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wagtail_unirate-0.1.0.tar.gz.
File metadata
- Download URL: wagtail_unirate-0.1.0.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f4c6dc04d69e03a5c006d13c628208b30179c751740a1e0ef8316e8b8fdf261
|
|
| MD5 |
6d19b1baada36434def085feac4f0730
|
|
| BLAKE2b-256 |
caa54f72f5d7658f05c0f1fa0bfa91a28ac3d7e2e01c7b5e8d50198e0cda71f5
|
Provenance
The following attestation bundles were made for wagtail_unirate-0.1.0.tar.gz:
Publisher:
release.yml on UniRate-API/wagtail-unirate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wagtail_unirate-0.1.0.tar.gz -
Subject digest:
5f4c6dc04d69e03a5c006d13c628208b30179c751740a1e0ef8316e8b8fdf261 - Sigstore transparency entry: 1715995542
- Sigstore integration time:
-
Permalink:
UniRate-API/wagtail-unirate@3c7cfc1650077b26f08fc7e091903479829d0411 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/UniRate-API
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3c7cfc1650077b26f08fc7e091903479829d0411 -
Trigger Event:
push
-
Statement type:
File details
Details for the file wagtail_unirate-0.1.0-py3-none-any.whl.
File metadata
- Download URL: wagtail_unirate-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5e5fc3f12e0cf78d7ff7933c2691b0a9b7bb7b8e808a2bb9298b02afe3ae2f8
|
|
| MD5 |
7f9f03c8c2eaee3b0f57e67199d3f361
|
|
| BLAKE2b-256 |
612b35d3d80e826cf04fb426c7a28711103edba776d9fa2749176904b46c5178
|
Provenance
The following attestation bundles were made for wagtail_unirate-0.1.0-py3-none-any.whl:
Publisher:
release.yml on UniRate-API/wagtail-unirate
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
wagtail_unirate-0.1.0-py3-none-any.whl -
Subject digest:
a5e5fc3f12e0cf78d7ff7933c2691b0a9b7bb7b8e808a2bb9298b02afe3ae2f8 - Sigstore transparency entry: 1715995659
- Sigstore integration time:
-
Permalink:
UniRate-API/wagtail-unirate@3c7cfc1650077b26f08fc7e091903479829d0411 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/UniRate-API
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3c7cfc1650077b26f08fc7e091903479829d0411 -
Trigger Event:
push
-
Statement type: