[Django] #12173: hability to use OR in filterspecs

View: New views
2 Messages — Rating Filter:   Alert me  

[Django] #12173: hability to use OR in filterspecs

by Django-3 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

#12173: hability to use OR in filterspecs
----------------------------------+-----------------------------------------
 Reporter:  fgallina              |       Owner:  nobody    
   Status:  new                   |   Milestone:            
Component:  django.contrib.admin  |     Version:  1.1      
 Keywords:  filterspec, filter    |       Stage:  Unreviewed
Has_patch:  1                     |  
----------------------------------+-----------------------------------------
 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)

--
Ticket URL: <http://code.djangoproject.com/ticket/12173>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django updates" group.
To post to this group, send email to django-updates@...
To unsubscribe from this group, send email to django-updates+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: [Django] #12173: hability to use OR in filterspecs

by Django-3 :: Rate this Message:

Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message

#12173: hability to use OR in filterspecs
-------------------------------------------+--------------------------------
          Reporter:  fgallina              |         Owner:  nobody            
            Status:  new                   |     Milestone:                    
         Component:  django.contrib.admin  |       Version:  SVN              
        Resolution:                        |      Keywords:  filterspec, filter
             Stage:  Unreviewed            |     Has_patch:  1                
        Needs_docs:  0                     |   Needs_tests:  0                
Needs_better_patch:  0                     |  
-------------------------------------------+--------------------------------
Changes (by fgallina):

  * needs_better_patch:  => 0
  * version:  1.1 => SVN
  * needs_tests:  => 0
  * needs_docs:  => 0

--
Ticket URL: <http://code.djangoproject.com/ticket/12173#comment:1>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django updates" group.
To post to this group, send email to django-updates@...
To unsubscribe from this group, send email to django-updates+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---