title: Django objects.filter with args in loop
body: <p>I search a way to optimize my Django's research function (in python). At this time I have this :</p>
  
  <pre><code>def search(acronym=None, name=None, reference=None):
      queryset = Organization.objects
  
      if acronym:
          queryset = queryset.filter(acronym=acronym)
  
      if name:
          queryset = queryset.filter(name=name)
  
      if reference:
          queryset = queryset.filter(reference=reference)
  
      return queryset
  </code></pre>
  
  <p>The problem is, each time I add an argument, I have to add an if + filter, etc.
  There is a way to put this in a loop ?</p>
  
  <p>For example :</p>
  
  <pre><code>  def search(acronym=None, name=None, reference=None):
      queryset = Organization.objects
      for arg in args : 
          if arg :
              queryset = queryset.filter(arg = arg)
      return queryset
  </code></pre>
  
  <p>or something like that ?</p>
  
  <p>Thanks in advance</p>