2👍
I found the answer myself. Basically the [:n]
puts a SQL "LIMIT" in the query which makes the query itself NOT exhaustive. So it’s fine in terms of efficiency.
Link for similar answer below.
https://stackoverflow.com/a/6574137/4775212
0👍
If the limit is known, it can also be using range.
Message.objects.filter(chat__range=[chat_id, chat_id+n]).order_by('-id')
- [Django]-How to rewrite base url in django to add logged in username in the url of all pages instead of app name?
- [Django]-Refrehing the Django model after save and 5 second sleep get me old state, what's wrong?
Source:stackexchange.com