Opened 15 years ago
Closed 15 years ago
#12173 closed (duplicate)
hability to use OR in filterspecs
Description ¶
Currently when creating filterspecs we only can combine several rules using AND only.
This patch adds the hability to use OR in the query.
Why this could be useful? ¶
Suppose we have a Taxes model which contains a due_date field and a payed_date field and we want to filter the non due taxes.
So non due taxes would be:
Q(due_date__gt=datetime.date.today()) | Q(payed_date__is_null=False)
How we do that? ¶
When creating a filterspec prepend the value of FILTERSPEC_OR_PREFIX (the value in the patch is '__or__'
) to your fields like this:
[...] self.links = ( (_('Non Due'), {'%s__gte' % self.field.name: str(today.date()), '__or__payed_date__isnull' : 'False'}), ) [...]
PD: I also fixed a little typo in the line 208 (comment)
Change History (3)
by , 15 years ago
Attachment: | filterspec_or_support.patch added |
---|
comment:1 by , 15 years ago
Version: | 1.1 → SVN |
---|
comment:2 by , 15 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
#5833 covers a much broader range of improvements for filterspecs.
first proposal to support OR in filterspecs