title: Django ORM: construct query that would look for match on field in object at the last position of many to many field
body: <p>I stumbled upon something I can't figure out by myself - while filtering (in Django ORM) query I would like to query for objects meeting condition, that some field of last object in the list of many to many objects is equal to some input. It may sound not so obvious, so below I provide an example:
  <strong>Animal model</strong></p>
  
  <pre><code>class Animal(models.Model):
      name = models.TextField(null=True, blank=False)
      awards = models.ManyToManyField(Award, related_name='awards')
  </code></pre>
  
  <p><strong>Award model</strong> </p>
  
  <pre><code>class Award(models.Model):
      name = models.TextField(null=False, blank=False)
      place = models.TextField(null=True, blank=True)
      date = models.DateTimeField(null=True)
  
      class Meta:
          ordering = ['date']
  </code></pre>
  
  <p>Having these classes, I would like to construct query like this:</p>
  
  <pre><code>Animal.objects.filter(awards__name__last='National Award')
  </code></pre>
  
  <p>Because <code>Animal.objects.filter(awards__name='National Award')</code> normally returns (when using <code>.values()</code>) list looking like this:</p>
  
  <pre><code>[{'name': u'National Award', 'place': u'capital', 'date': datetime.datetime(2018, 7, 13, 5, 2, 45, 23000), u'id': 1}, {'name': u'International Award', 'place': u'capital', 'date': datetime.datetime(2018, 10, 1, 1, 1, 55, 79000), u'id': 2}]
  </code></pre>
  
  <p>and for such object, query would ommit it, because 'National Award' is not on the last position on the list, but if this object would have switched these entries, it would be returned by this query, since the last object <code>name</code> is equal to 'National Award'. I do not want to use <code>date</code> field for this query.</p>