Let’s say I have the following Django model:
class Info(models.Model):
instrument = models.ForeignKey('Instrument')
date = models.DateTimeField()
How can I extract the entry with the newest date for each Instrument ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try this:
It will return a list of all instruments and each intrument will have additional attribute
max_datewhich contains the latest date for this instrument.