What is the Best way to get only 10 rows in django ORM

Viewed 153

I have Grid-view it only show 10 records on time . What is the best way to get from database only 10 rows? Is MyModel.objects.all()[10:20] approprate .

1 Answers

You are doing it correctly. The django docs also have examples on this.

>>> Entry.objects.all()[5:15]

Since I don't know your use case, maybe pagination is also something that might suite your needs.

Related