Django Object Filter (last 1000) -
How will be known about retrieving previous 1,000 values from a database by Objects.filter? What I am currently doing is bringing me 1,000 values before entering the database (i.e. 10,000 lines and this is bringing me 1-1000 instead of 9000-1000).
Current code: <
Border = 1000 store. Afs. (Id = some other [id]) [: border]
Cheers
solution:
queryset = shop.objects.filter (id = someArray [id]) border = 1000 count = queryset.count () endoflist = queryset.order_by ('timestamp ') [Count-Limit:]
Endowlist
is the query that you want.
Efficiency:
The following queries are from the Dedango docs about the method.
To query a "last" five items, you can:
my_queryset.reverse () [: 5] < / Code>
Note that this is not exactly the same as the slicing action. End of the sequence in Python The above example will first return to the last item, then the suburban object and so on. If we had a Python sequence and saw that seq [-5:], then we would see the fifth-final item first. Django does not support that mode of access (truncation from the end), because it is not possible to do it efficiently in SQL.
So I am not sure whether my answer is only disabled, or too highly disabled, I was taken to the order_by
for the last question, but I am not sure It makes a difference.
Comments
Post a Comment