[Django]-Is it right to call News.objects.all()[:x] to fetch fixed number of records

3👍

This is safe as QuerySets as lazy. At most ten objects will be fetched in your case as the database query will be optimized to return only ten records from the database.

You can read more about when QuerySets are evaluated and limiting QuerySets (this section deals with slicing QuerySets which is what you are doing).

Leave a comment