- first() and last():

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

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

Last updated