Django In fact, there is a built-in paging method , But the results shared by other people on the Internet show that this method will be significantly slower in the case of millions of data .
So I kept searching , It turns out that another method is more efficient .
The principle is ORM When getting the results , Take advantage of its inert properties , Get only the specified quantity Result . The performance is greatly improved .
Specific code :
def getArtical(request):
all_english = models.Artical.objects.filter(category=‘english’).all()[0:20]