title: icontains and getlist django python
body: <p>We are trying to return a list of titles for the Django API, in which the title can have a few keywords.</p>
  
  <p>So for instance, if we use the <code>__icontains</code> method to search for "money" and "world" (<code>api.com/?keyworld=money&amp;keyword=world</code>) this will return all records that contain money, world or both.</p>
  
  <p>The related SQL statement is:</p>
  
  <pre><code>select * from news
      where news_source = 1 or news_source = 2
          and news_title like '%money%' or news_title like '%world%'
  </code></pre>
  
  <p>We are trying to use this code to allow the user to have multiple keywords for the <code>__icontains</code> as well as multiple sources, so the end goal is:</p>
  
  <pre><code>api.com/?keyworld=money&amp;keyword=world&amp;source=1&amp;source=2
  </code></pre>
  
  <p><strong>Our code:</strong></p>
  
  <pre><code>def get_queryset(self):
      queryset = News.objects.all()
      title = self.request.query_params.getlist('title')
      source = self.request.query_params.getlist('source')
      if title:
          queryset = queryset.filter(news_title__icontains=title, news_source__in=source)
      return queryset
  </code></pre>
  
  <p>The issue is that this is only returning the second keyword if a second keyword is used, and not other keywords prior to what is typed in <code>&amp;keyword=</code>.</p>