On 3/15/07, johnny <[EMAIL PROTECTED]> wrote:
> I need to retrieve latest record (each record has a time stamp,
> created_at), only one record, from sale table where product_id=1.  How
> do I do this in Django ORM?  I have looked at .objects.extra{}, but I
> am getting ProgrammingError 1064.

OK, so assuming the models are named 'Sale' and 'Product':

Sale.objects.filter(product__pk=1).order_by('-created_date')[0]


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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