Ticket #11283: query_latest_ordering.diff

File query_latest_ordering.diff, 932 bytes (added by punteney, 15 years ago)

adding a test to the patch

  • django/db/models/query.py

     
    353353                "Cannot change a query once a slice has been taken."
    354354        obj = self._clone()
    355355        obj.query.set_limits(high=1)
     356        obj.query.clear_ordering()
    356357        obj.query.add_ordering('-%s' % latest_by)
    357358        return obj.get()
    358359
  • tests/modeltests/get_latest/models.py

     
    7676
    7777>>> Person.objects.latest('birthday')
    7878<Person: Stephanie>
     79
     80# Checking to ensure latest() overrides any other ordering specified on the query
     81>>> Article.objects.order_by('id').latest()
     82<Article: Article 4>
    7983"""}
Back to Top