Hey,
Thanks for your prompt reply *Tim & luisza14*, i have gone through the
documentation. From what i have understood:
When we get all objects from the queryset = User.objects.all() it cache the
result and it is better to filter it from this result than hitting the db
on every subsequent requ
Querysets are lazy, so Model.objects.all().filter(...) execute a same
query that Model.objects.filter(...).all() and Model.objects.filter(...).
For check this tray in shell
str(Model.objects.all().filter(pk=1).query)
str(Model.objects.filter(pk=1).all().query)
str(Model.objects.filter(pk=1).q
Have you had a look at the documentation?
https://docs.djangoproject.com/en/stable/topics/db/optimization/#understand-querysets
On Monday, June 22, 2015 at 11:28:51 AM UTC-4, Paritosh Gupta wrote:
>
> Hello,
>
> Do advice me on:
>
> queryset = User.objects.all()
> user = get_object_or_404(pk=id)
>
Hello,
Do advice me on:
queryset = User.objects.all()
user = get_object_or_404(pk=id)
> Is it better to call the list in queryset and then apply filter or
directly use .filter() in the first step.
> If so, when we call all the object frequently does it cache and from
cache we do filter or d
4 matches
Mail list logo