Hi,

I'm using the following to pull all cost prices that match a
particular product by the company that supplied the product:

View:

cost_prices = ProductCostPrice.objects.filter
(product_id__product_id=product_id)

Template:
...
{% regroup cost_prices|dictsort:"supplier" by supplier as cost_list %}
  {% for cost in cost_list %}
    {% for item in cost.list %}
        <tr>
          <td>{{ item.date_cost|date:"d/m/Y" }}</td>
          <td>{{ item.supplier }}</td>
          <td>{{ item.cost_price_gross }}</td>
         </tr>
    {% endfor %}
  {% endfor %}

Works great - only thing is that in some cases there is more than one
cost price in the db for a supplier, how do I just grab the latest
price entered for each supplier?  Familiar with latest() lookup but
not sure about it's use in the above scenario. I feel I should know
this but can't make it work.  FYI there is normally more than one
supplier for a product hence why it's set up like this.

Thanks!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to