That looks great Alex, thanks a lot. Also being a Python noob I wasn't
aware you could chain together operators in that way. (I assumed, like
C# you could only use += or -=, but |= is very cool).
Surrounded by geniuses...I love it!
-M
On Jan 5, 5:09 pm, "alex.gay...@gmail.com"
wrote:
> You need
On 5 jan, 18:09, "alex.gay...@gmail.com"
wrote:
> You need to build up the Q object and then filter on it so:
> results = RelatedModel.objects.all()
> q = Q()
> for category in category_list:
> q |= Q(categories__slug = category.slug)
> results = results.filter(q)
Or create a sequence of Q
Hi Mark,
I think you could use the Q object like this:
q_filter = Q()
for category in category_list:
q_filter = q_filter | Q(categories__slug=category.slug)
results = RelatedModel.objects.filter(q_filter)
Best regards,
Enrico
--~--~-~--~~~---~--~~
You receive
You need to build up the Q object and then filter on it so:
results = RelatedModel.objects.all()
q = Q()
for category in category_list:
q |= Q(categories__slug = category.slug)
results = results.filter(q)
On Jan 5, 10:52 am, Bluemilkshake
wrote:
> Hello. Django noob here, pretty much.
>
> I
On Mon, Jan 5, 2009 at 11:59 PM, Ronny Haryanto wrote:
> On Mon, Jan 5, 2009 at 11:52 PM, Bluemilkshake
> wrote:
>> for category in category_list:
>>results = results.filter(categories__slug = category.slug)
>
> How about results.filter(category__in=category_list)?
Whoops. Never mind. Repli
On Mon, Jan 5, 2009 at 11:52 PM, Bluemilkshake
wrote:
> for category in category_list:
>results = results.filter(categories__slug = category.slug)
How about results.filter(category__in=category_list)?
Ronny
--~--~-~--~~~---~--~~
You received this message bec
Hello. Django noob here, pretty much.
I understand how one can use Q objects to construct OR statements
within a QuerySet, but (how) is it possible to do this dynamically?
I have a list of categories, and I want to find items that match ANY
of those categories. The current solution doesn't work
7 matches
Mail list logo