Given this model, I want to find all ProductSale objects that have expired and where the Person doesn't have a later (unexpired) purchase of the same product.
class ProductSale(models.Model):
product = models.ForeignKey(Product)
person = models.ForeignKey(Person)
...
date_expires = models.DateField(blank=True, db_index=True)
The closest I've gotten is in the shell where I get a values_list of person and product for expired and unexpired and then compare the two lists. That leaves me with a list of tuples, that (due to the size of the list, I think) I can't use in a query.extra.
Any suggestions would be appreciated.
(and sorry for the lame subject. I couldn't think of a way to be both succinct and informative.)