Re: manually add objects to a QuerySet

2010-08-11 Thread John M
I asked a similar question like, I want to sort a QS on a meta field, can it be done? The answer worked, and is the same one you're getting, use a list. qs1 = model1.objects.filter(...) qs2 = model2.objects.filter(...) lqs1 = list(qs1) lqs2 = list(qs2) now you have something that is a python li

Re: manually add objects to a QuerySet

2010-08-09 Thread Daniel Roseman
On Aug 9, 8:13 am, chefsmart wrote: > I already have the objects in an earlier chunk of the code. I don't > want to hit the database again to get something I already have in > another form. That is what I mean when I say that code like my_qs = > MyModel.objects.filter(pk=obj1.pk) is utterly silly.

Re: manually add objects to a QuerySet

2010-08-09 Thread chefsmart
I already have the objects in an earlier chunk of the code. I don't want to hit the database again to get something I already have in another form. That is what I mean when I say that code like my_qs = MyModel.objects.filter(pk=obj1.pk) is utterly silly. I already have the objects from earlier db q

Re: manually add objects to a QuerySet

2010-08-08 Thread chefsmart
Since I already have the objects, I don't want to hit the database again. There are not just two but multiple objects, that's why I want to avoid unnecessary db calls. On Aug 8, 9:54 pm, akaariai wrote: > On 8 elo, 11:55, chefsmart wrote: > > > The objects are coming from mutually exclusive quer

Re: manually add objects to a QuerySet

2010-08-08 Thread akaariai
On 8 elo, 11:55, chefsmart wrote: > The objects are coming from mutually exclusive querysets. I need to > pass a queryset of these objects to a function. "Or" the querysets together? In [2]: f1 = Foo1() In [3]: f1.save() In [4]: f2 = Foo1() In [5]: f2.save() In [6]: [f.pk for f in Foo1.objects.a

Re: manually add objects to a QuerySet

2010-08-08 Thread chefsmart
The objects are coming from mutually exclusive querysets. I need to pass a queryset of these objects to a function. On Aug 8, 1:25 pm, Masklinn wrote: > On 8 août 2010, at 06:15, chefsmart wrote: > > > I had asked this on stackoverflow, but I guess I couldn't explain > > myself clearly enough. I

Re: manually add objects to a QuerySet

2010-08-08 Thread Lakshman Prasad
You can't really add an object to queryset like that. If you don't want to generate a list in the view, you can chain the querysets chained_qs = chain(qs1,qs2) On Sun, Aug 8, 2010 at 9:45 AM, chefsmart wrote: > I had asked this on stackoverflow, but I guess I couldn't explain > myself clearly

Re: manually add objects to a QuerySet

2010-08-08 Thread Masklinn
On 8 août 2010, at 06:15, chefsmart wrote: > I had asked this on stackoverflow, but I guess I couldn't explain > myself clearly enough. I'll try to ask again here: > > Say I have two objects obj1 and obj2 of the same model (MyModel), now > I would like to add these objects to a new QuerySet. Can