This is a continuation of this post in which I use django-formset and detailview.
Let's see a customer orders an item on June 3rd. How can I retrieve the latest price of that item before June 3rd, which is $2?
I have the following django template tags, but it returns $4.
{% for cartitem_ in object.model_customercartitem_set.all %}
{% for pricerow_ in cart_item.item_name.model_itemprice_set.all %}
{% if price_row.timestamp|date:"U" <= object.timestamp|date:"U" %}
{% if forloop.first %}
{{ price_row.item_price }}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
Perhaps I have used forloop.first tag incorrectly, so what should the right tag be? Any other solution besides template tag works too.
Thanks