{% extends 'base.html' %} {% block title %}Price Trends — Admin{% endblock %} {% block content %}
Admin Portal

Regional Price Trends

← Back to portal

Record a new farm/market price for a product in a region. The percentage change and up/down/tied direction shown everywhere in the app are always calculated automatically from the previous entry — never typed in manually.

{% csrf_token %} {% for field in form %} {{ field }} {% if field.errors %}
{{ field.errors }}
{% endif %} {% endfor %}
{% for product in products %}
{{ product.name }} {% if product.price_badge %} {% if product.price_badge.direction == 'up' %}▲{% elif product.price_badge.direction == 'down' %}▼{% else %}—{% endif %} {% if product.price_badge.change_pct != None %}{{ product.price_badge.change_pct }}%{% else %}new{% endif %} {% endif %}
{% if product.regional_trends %} {% for t in product.regional_trends %} {% endfor %}
RegionFarm PriceMarket PriceTrendLast updated
{{ t.region }} TSh {{ t.farm_price|floatformat:0 }} TSh {{ t.market_price|floatformat:0 }} {% if t.change_pct != None %} {% if t.direction == 'up' %}▲{% elif t.direction == 'down' %}▼{% else %}—{% endif %} {{ t.change_pct }}% {% else %} first entry {% endif %} {{ t.recorded_at_display|date:"d M Y, H:i" }}
{% if product.price_history %}
View full price history ({{ product.price_history|length }} update{{ product.price_history|length|pluralize }}) — see how this product has fluctuated over time {% for h in product.price_history %} {% endfor %}
Date & timeRegionFarm PriceMarket PriceChange
{{ h.recorded_at_display|date:"d M Y, H:i" }} {{ h.region }} TSh {{ h.farm_price|floatformat:0 }} TSh {{ h.market_price|floatformat:0 }} {% if h.change_pct != None %} {% if h.direction == 'up' %}▲{% elif h.direction == 'down' %}▼{% else %}—{% endif %} {{ h.change_pct }}% {% else %} first entry {% endif %}
{% endif %} {% else %}

No price history recorded yet for this product.

{% endif %}
{% endfor %}
{% endblock %}