Hi there,
Given an object like:
class M(models.Model):
test = models.BooleanField()
created_date = models.DateTimeField(auto_now_add=True)
Given sample data (assume monotonically increasing automatic created_date):
M(test=False).save()
M(test=True).save()
M(test=False).save()
X = M(test=True).save()
M(test=False).save()
Y = M(test=False).save()
M(test=False).save()
M(test=True).save()
Can one use the Django ORM to create a query that would return X (the previous query, by date, where 'test'=True), if you are given Y? If so, how?
In other words: Given Y, how does one get the most recent previous element where 'test' is True?
Thoughts & feedback is appreciated, thanks!