Return the latest object according to fields (if given) or by the model's Meta.get_latest_by.
(self, *fields)
| 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) |