> For the complete documentation index, see [llms.txt](https://olee-tech.gitbook.io/django/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://olee-tech.gitbook.io/django/django-orm/basic-database-operation/first-and-last.md).

# - first() and last():

\- **first()** and **last()**: To retrieve the first or last record in a queryset, you can use the .first() and .last() methods.

```python
from .models import BlogPost
first_post = BlogPost.objects.first()
last_post = BlogPost.objects.last()
```
