[Answer]-QuerySet and Limit

1👍

See https://docs.djangoproject.com/en/dev/topics/db/queries/#limiting-querysets

It is equivalent to

SELECT * FROM `Model` WHERE `premmium` = True LIMIT 20;

However, it is worth noting that using slices like this is not always the most efficient way of querying because of the way the results are cached (see here). Often, if you data set is not huge, it is more efficient to slice in python:

list(Model.objects.filter('premmium' = True))[:20]

Leave a comment