MCPcopy
hub / github.com/django/django / latest

Method latest

django/db/models/query.py:1170–1177  ·  view source on GitHub ↗

Return the latest object according to fields (if given) or by the model's Meta.get_latest_by.

(self, *fields)

Source from the content-addressed store, hash-verified

1168 return await sync_to_async(self.earliest)(*fields)
1169
1170 def latest(self, *fields):
1171 """
1172 Return the latest object according to fields (if given) or by the
1173 model's Meta.get_latest_by.
1174 """
1175 if self.query.is_sliced:
1176 raise TypeError("Cannot change a query once a slice has been taken.")
1177 return self.reverse()._earliest(*fields)
1178
1179 async def alatest(self, *fields):
1180 return await sync_to_async(self.latest)(*fields)

Calls 2

reverseMethod · 0.95
_earliestMethod · 0.80