Thanks for the answer, I just wondered if there was a built-in solution in
Django.
On 27/09/14 06:01, tkdchen wrote:
>
>
> On Saturday, September 27, 2014 9:06:58 PM UTC+8, aRkadeFR wrote:
> >
> > @James Brewer:
> > If I change my code, I can have this user_ids list.
> > btw, it's filter and
On Saturday, September 27, 2014 9:06:58 PM UTC+8, aRkadeFR wrote:
>
> @James Brewer:
> If I change my code, I can have this user_ids list.
> btw, it's filter and not get if you're searching multiple objects (the
> user_ids).
>
> @Alejandro Varas G.:
> That doesn't change the fact that
@James Brewer:
If I change my code, I can have this user_ids list.
btw, it's filter and not get if you're searching multiple objects (the
user_ids).
@Alejandro Varas G.:
That doesn't change the fact that 'User.objects.get(id=X)' will hit the
database everytime.
Right now, the problem is solved,
Do you have a single list of the IDs you want? If so, you can do something
like `User.objects.get(id__in=user_ids)`. This will fetch all Users whose
`id` is in some list `user_ids`.
Does that help?
Happy hacking!
James
On Fri, Sep 26, 2014 at 11:43 AM, Alejandro Varas G.
Hi,
You should use User.objects.get(id=X)
Best
El 26/09/2014 15:28, "aRkadeFR" escribió:
>
> Hey!
>
> I'm having a hard time trying to reduce the number of SQL queries on a
view.
>
> Basically, I'm fetching all my User, with User.objects.all(), and save
this
> queryset as
Hey!
I'm having a hard time trying to reduce the number of SQL queries on a view.
Basically, I'm fetching all my User, with User.objects.all(), and save this
queryset as AllUser.
Then every time I need to get the user with the id = X , I'm calling a function
'get_user_from_id', that iterate
6 matches
Mail list logo