These are chat archives for django/django

21st
Aug 2016
Peter Bittner
@bittner
Aug 21 2016 12:26
@wqhhust Don't add the obj.bidding_id to the string with +. Use string formatting instead (e.g. '<a href="http://.../%s">test</a>' % obj.bidding_idor '<a href="http://.../{}">test</a>'.format(obj.bidding_id)). You'll run into a TypeError with this style of coding sooner or later.
Ramon Moraes
@vyscond
Aug 21 2016 15:01
what's up my helsings?
Alexey Kalinin
@Alkalit
Aug 21 2016 15:04

I have 3 models http://pastebin.com/24xFQtv7
I need to filter Ad with condition:

(category1: filter1 OR filter2 OR filter3) AND (category2: filter4 OR filter5 OR filter6) AND (categoryN: OR ) AND (etc)
How can I do it in django ORM?

Ramon Moraes
@vyscond
Aug 21 2016 15:43
@Alkalit maybe using an advanced Q object
@Alkalit or doing an chained filters? (real bad performance though)
@Alkalit something like
cat1 = FilterCategory.objects.filter(filters__in=[1, 2, 3])
then using Ad.objects.filter(filters__in=[cat1, cat2, catN]) ?
Alexey Kalinin
@Alkalit
Aug 21 2016 16:16
@vyscond Thanks mate!
@vyscond it was so obvious and I was so stupid.