short sentence.
Lets say I have two models (using pseudo code):
Book(model.Model):
name = charfield()
Transaction(model.Model):
start_date = DateTimeField()
item = ManytoMany(Book)
recipient = CharField()
Now for every book, I want to know the recipient of only the most
recent transaction. I can get the start date of the most recent
transaction for each book with
Book.objects.annotate(mostrecent = Max('transaction__start_date'))
but what I would like is the pk of that transaction, so I can get more
information about it. Can this be done even in multiple queries?
Must I hack a solution using lists instead of queries?
I have simplified my question quite a bit, I hope not too much.
thanks for reading,
Elliot
--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment